Idézem/Quoting Ralph Corderoy <[email protected]>:
Hi Steffen,
?0[steffen@wales nail.git]$ dash -c "printf 'Hello\\\"\n'"
Hello\"
?0[steffen@wales nail.git]$ bash -c "printf 'Hello\\\"\n'"
Hello"
I should have double quoted LF as \\n
$ python -c '
> import sys
> print([c for c in sys.argv[1]])
> ' "printf 'Hello\\\"\n'"
['p', 'r', 'i', 'n', 't', 'f', ' ', "'", 'H', 'e', 'l', 'l', 'o',
'\\', '"', '\\', 'n', "'"]
$
It's the «\\» before the «\"» causing the problem; it's unspecified.
One ends up with printf seeing «\"» and my printf(1p) says
The interpretation of a <backslash> followed by any other sequence
of characters is unspecified.
Without it, I get consistent results.
$ bash -c "printf 'Hello\"\n'"
Hello"
$ bash -c "printf 'Hello\"\n'" | sha1sum
f8edb41250edb3fea02ea9cb68488b123773b559 -
$ dash -c "printf 'Hello\"\n'" | sha1sum
f8edb41250edb3fea02ea9cb68488b123773b559 -
Hello!
Using b/dash -c ".." to switch shell is very misleading. Inside
double-quotes escaped characters loose their backslashes!
Please try with one file each shell:
#!/bin/dash
printf 'Hello\"\n'
then ./test-dash.sh | sha1sum
SZÉPE Viktor, üzemeltetés
https://github.com/szepeviktor/debian-server-tools/blob/master/CV.md
--
+36-20-4242498 [email protected] skype: szepe.viktor
Budapest, III. kerület