John McKown wrote, On 2015-04-03 14:19: > Note that testbug.sh does end in a LF, at least if I did it correctly.
I've noticed that actually the LF is not important, only the final backslash is: $ alias hi=echo\ hello Without final LF: $ echo -n true\\ > testbug.sh $ . testbug.sh $ hi bash: hi: command not found $ hi hello With final LF (same case as initially submitted): $ echo true\\ > testbug.sh $ . testbug.sh $ hi bash: hi: command not found $ hi hello But if there is one more LF it doesn't reproduce: $ echo true\\ > testbug.sh $ echo >> testbug.sh $ . testbug.sh $ hi hello In the first case the file is malformed, so that's not a problem. I think the second case should act as if the last command was in a line by itself without a terminating newline, but that's not what happens. It can also be argued that in that case the file is malformed too. In my real use case, the last lines were a set of options to which I was constantly adding or removing, with a backslash at the end of each line. At one point I wasn't careful and didn't remove the backslash from the last line. As I said, the next thing I did was to delete a file, and that's how I noticed it didn't prompt me for confirmation. I can easily add a ; in one line alone at the end of the file and insert the options before it. That'd work around this. > Since testbug.sh terminates with a \, it appears that the BASH shell > is "seeing" your second command as \hi. Which _appears to me_ is what > BASH would call a "quoted value". And it is documented that aliases > are not expanded when quoted. On the other hand, this works as expected: $ echo true\\ > testbug.sh $ . testbug.sh $ "hi" bash: hi: command not found My point with this last example is that it's not quoting the double quotes as if they were prefixed with a backslash. This is what happens when that's the case: $ \"hi" > So it's not as simple as "it acts as if preceded by a backslash". Also, it doesn't reproduce if the aliased command is inside the sourced file: $ echo true\\ > testbug.sh $ echo hi >> testbug.sh $ . testbug.sh bash: truehi: command not found (which is expected). $ echo true\\ > testbug.sh $ echo >> testbug.sh $ echo hi >> testbug.sh $ . testbug.sh hello (which is expected too).