HISTTIMEFORMAT messed up adb
I set up earlier this month HISTTIMEFORMAT
cause I needed to see the time on some of the commands I previously used. However, I most likely messed something up with those commands, because every time I try to use adb for anything (adb kill-server eg.) I get the following error: bash: /home/user/Android/Sdk/platform-tools/adbHISTTIMEFORMAT=%d%m%y: No such file or directory
. These are the commands that I used to setup HISTTIMEFORMAT
:
1032 20/05/22 19:17:45 echo 'HISTTIMEFORMAT="%d%m%y %T "' >> ~/.bashrc
1033 20/05/22 19:17:46 history
1034 20/05/22 19:19:17 source ~/.bashrc
1035 20/05/22 19:19:19 history
1036 20/05/22 19:20:22 echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
1037 20/05/22 19:20:32 source ~/.bashrc
What exactly did I do wrong and how can I fix/revert it?
Hypothesis: your old ~/.bashrc
contained an incomplete line and the line was related to adb
. Your command
echo 'HISTTIMEFORMAT="%d%m%y %T "' >> ~/.bashrc
added to the line instead of adding another line. This behavior is one of the reasons the last line should be properly terminated.
My tests indicate an incomplete line in ~/.bashrc
is not ignored by Bash. You may have had an incomplete alias …
line that worked. Your incomplete line might be:
alias adb='/home/user/Android/Sdk/platform-tools/adb'
(maybe without the single-quotes) and after the first echo … >> ~/.bashrc
it became:
alias adb='/home/user/Android/Sdk/platform-tools/adb'HISTTIMEFORMAT="%d%m%y %T "
(maybe without the single-quotes). The line neither defines the exact alias you wanted, nor affects HISTTIMEFORMAT
. It’s a complete line though, so your second echo … >> ~/.bashrc
worked as intended and created a separate line that actually affects HISTTIMEFORMAT
.
In a comment you wrote:
I tried removing that line from the bashrc file, but it just removed the timestamp from the history command. The adb error is still there.
Removing the last line (i.e. the output of the second echo
) without noticing that the previous line is contaminated (with the output of the first echo
) would do exactly this. My hypothesis stands.
Check the last line of your ~/.bashrc
.