On Tue, Apr 3, 2018 at 3:35 AM, Herbert Xu <herb...@gondor.apana.org.au> wrote:
> On Mon, Apr 02, 2018 at 08:57:35PM +0200, Denys Vlasenko wrote:
>>
>> I see this:
>>
>> $ x='\t'; echo "[$x]"
>> [    ]
>>
>> I'm pretty sure this isn't okay...
>
> Why not? dash has always behaved like this and this is explicitly
> required by POSIX:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html

I totally forgot that dash's echo differs from bash. Sorry.

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 \".
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to