SZÉPE Viktor <[email protected]> wrote:
 |Idézem/Quoting Ralph Corderoy <[email protected]>:
 |> Hi Viktor,
 |>
 |>>>     ['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  -
 |>>
 |>> Using b/dash -c ".." to switch shell is very misleading. Inside
 |>> double-quotes escaped characters loose their backslashes!
 |>
 |> Well, that's not quite true, as I showed above.
 |
 |Yes. In single quotes a double quote should not be escaped.

Yes, like i said.  My fault anyway.  The rules of the shell appear
inconsistent to me, sometimes, it is even worse inside ${}
constructs and especially so if quoting is involved inside there
in addition.  There are also i think still open POSIX standard
issues related these things.  I would claim that only very few
people get that right right away, and to me the question would be
how many of those in fact reveal indeed the outcoming of
"addictive behaviour".  To me: these rules are sick.  But because
of historical reasons, of course, of course.  I do not accuse
anybody.  Nonetheless of know of my weaknesses regarding those
rules and should avoid running into those traps, but did not.
Quite honestly, all that a pain in the a.s.:

  ?0[wales]$ bash -c "echo '\'"
  \
  ?0[wales]$ bash -c "echo \ "

  ?0[wales]$ bash -c "echo a\ b"
  a b
  ?0[wales]$ bash -c "echo a\\ b"
  a b
  ?0[wales]$ bash -c "echo a\\\ b"
  a\ b
  ?0[wales]$ bash -c "echo 'a\\\ b'"
  a\\ b
  ?0[wales]$ mksh -c "echo '\'"
  \
  ?0[wales]$ mksh -c "echo \ "

  ?0[wales]$ mksh -c "echo a\ b"
  a b
  ?0[wales]$ mksh -c "echo a\ b"
  a b
  ?0[wales]$ mksh -c "echo a\\ b"
  a b
  ?0[wales]$ mksh -c "echo a\\\ b"
  a\ b
  ?0[wales]$ mksh -c "echo 'a\\\ b'"
  a\ b

Ciao.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

Reply via email to