Package: posh
Version: 0.12.3
Severity: normal

The canonical example is:

  $ printf "%s %s\n" $(
    printf "%s\n" "$(printf "%s\n" 'START\
    NOLINE')"
    )

that prints "STARTNOLINE\n" instead of "START\\ NOLINE\n".  This is an
incorrect behaviour according to
http://pubs.opengroup.org/onlinepubs/000095399/utilities/xcu_chap02.html#tag_02_06_03:

" Any valid shell script can be used for command, except a script
  consisting solely of redirections which produces unspecified results. "

Note that this bug is found in pdksh but it has been fixed in mksh;
Debian stable has a non buggy pdksh 40.9.20120630-7 (provided by mksh)
while pdksh PD KSH v5.2.14 99/07/13.2 is buggy.

See the joined script for more examples.

Regards
-- 
G.raud Meyer
#!/bin/posh
NL='
'
echo This is incorrect behaviour
printf "%s %s\n" $(
printf "%s\n" "$(printf "%s\n" 'START\
NOLINE')"
)
printf "%s %s\n" "$(
printf "%s %s\n" "$(
printf "%s %s\n" "$(printf "%s\n" 'START\
NOLINE')"
)"
)"

echo This is a workaround
printf "%s %s\n" "$(
printf "%s %s\n" "$(printf "%s\n" 'START\'"$NL"'LINE')"
)"

echo These are cases that do not exhibit the behaviour
printf "%s %s\n" "$(printf "%s\n" 'START\
LINE')"
printf "%s %s\n" "$(
printf "%s %s\n" $(printf "%s\n" 'START\
LINE')
)"
printf "%s %s\n" "$(
printf "%s %s\n" "$(printf "%s\n" 'START
LINE')"
)"

Reply via email to