I typed an mv command and intended to hit the Enter key. Perhaps I hit the backslash key at almost the same time. If the Enter key was first, the new line with the green prompt should appear to the left of (before) the backslash. Instead the backslash is to the left of the green prompt.

There is second backslash and perhaps it starts an escape sequence. Why did the color of the prompt change to white when my usual prompt color is green? I am not sure if I typed the second backslash or if it is somehow an "erroneous second echo".

The file move happened successfully but this inquiry is just to check that no extraneous files were created in strange places. "Move" implies that one file will be moved to one place so it seems there will not be an extraneous file created.



Instead the backslash is to the left of the green prompt.

Because the backslash you typed printed before the prompt was output. And then the prompt was output, and the backslash you typed was added to it.

Why did the color of the prompt change to white when my usual prompt color is green?

Because your $PS1 is green, but your $PS2, which is what is shown when waiting for line completion, is not. Once the line has been completed (because a backslash at the end of a line continues the line), the prompt will go back to $PS1.


My testing shows that if I hit both Enter and backslash keys at almost the same time, this can be reproduced. Assuming the keyboard is well "debounced" (link to info about debouncing) then there was only a single backslash typed so in fact there is a "spurious second echo".

The (single) backslash key can be "deleted" via backspace but only one of the two echos will disappear. The echo to the right of the green prompt will disappear when backspace is keyed. The echo to the left of the green prompt cannot be removed. Apparently I did not "delete" it and proceeded to use the Enter key again. The backslash Enter pair is a line continuation sequence which works inside scripts but apparently also interactively. As mentioned by @IgnacioVazquez-Abrams the prompt becomes the one assigned to continued lines and in my case it happens to have a different appearance that is not the same as my usual green prompt.

In my testing, if backspace is used to "delete" the backslash (even though only one of the two echos will be removed) there is no line continuation. This is demonstrated by using the backspace to "delete" the backslash and then hitting the Enter key. In my test the prompt remained green which means that there was no line continuation sequence formed.

The mv command was not affected by the backslash because the Enter key was pressed slightly before the backslash. Proof of this is that the backslash appears on a new line (albeit before the green prompt) which means Enter, which echos as a newline, apparently was pressed first. Since the mv command was not affected by the backslash there will be no unexpected files created.

I believe I have seen similar behaviour when using ssh and I am typing fast. The remote host cannot prompt for the password soon enough so part of my password gets echoed to the left of the password prompt and may be echoed to the right of it also. I don't remember whether the password is obfuscated in both places or only on the right of the prompt.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.