Can someone explain this to me, please?
$ set -x
$ export X="--vendor Bleep\ Bloop"; echo $X
+ export 'X=--vendor Bleep\ Bloop'
+ X='--vendor Bleep\ Bloop'
+ echo --vendor 'Bleep\' Bloop
--vendor Bleep\ Bloop
$
Specifically, why does the echo
line insert '
characters that I didn't ask for, and why does it leave the string looking unterminated?
Bash performs shell expansions in a set order. The -x flag allows you to see the intermediate results of the steps that Bash takes as it tokenizes and expands the words that compose the input line.
In other words, the output is operating as designed. Unless you're trying to debug tokenization, word-splitting, or expansion, the intermediate results shouldn't really matter to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With