On Wed, Apr 04, 2018 at 01:56:42PM +0200, Denys Vlasenko wrote: > > This is the example which is not affected by echo differences: > > cat <<EOF > -\"-\'-\`-\--\z-\*-\?- > `echo '-\"-\x-\`-\--\z-\*-\?-'` > $(echo '-\"-\x-\`-\--\z-\*-\?-') > EOF > > # bash z > -\"-\'-`-\--\z-\*-\?- > -\"-\x-`-\--\z-\*-\?- > -\"-\x-\`-\--\z-\*-\?- > # dash z > -\"-\'-`-\--\z-\*-\?- > -"-\x-`-\--\z-\*-\?- > -\"-\x-\`-\--\z-\*-\?- > > IOW: if `cmd` outputs \" in here document, it is converted to " > whereas bare \" in here document is passed verbatim as \", and > $(cmd) in here document also does not show this. > > Aha... I think `` in heredocs removes \ in commands before > running them. Thus, `echo '\"'` would run: echo '"' > > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03 > "Within the backquoted style of command substitution, <backslash> > shall retain its > literal meaning, except when followed by: '$', '`', or <backslash>" > > I think it should retain \" as \". It wasn't the backquote that removed the backslash but the here- document. This is expected behaviour as here-documents behave like double quotes so the backslash is indeed special when it precedes a double quote. As I said ksh93 does the same thing. Cheers, -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html