Hi, I test using plain BSD Shells.
I do not use any BASH extensions.

I looked into the problem, and still believe it is a fatal bug in dash.
Violating the POSIX semantics.

Here a Strip-Down example:

cat z.sh << 'EOF'
echo "fprintf(stderr, \"result: <plain>\\n\");"
echo "fprintf(stderr, \"result: <plain>\n\");"
echo 'fprintf(stderr, "result: <plain>\n");'
echo 'fprintf(stderr, "result: <plain>\\n");'
EOF


BSD-Shell
$ sh --version
Illegal option --

sh z.sh 
fprintf(stderr, "result: <plain>\n");
fprintf(stderr, "result: <plain>\n");
fprintf(stderr, "result: <plain>\n");
fprintf(stderr, "result: <plain>\\n");

BASH
$ bash --version
GNU bash, version 3.2.39(1)-release (i386-portbld-freebsd6.4)
Copyright (C) 2007 Free Software Foundation, Inc.

$ bash z.sh 
fprintf(stderr, "result: <plain>\n");
fprintf(stderr, "result: <plain>\n");
fprintf(stderr, "result: <plain>\n");
fprintf(stderr, "result: <plain>\\n");


dash-0.5.4-12 (debian)

$ dash z.sh 
fprintf(stderr, "result: <plain>
");
fprintf(stderr, "result: <plain>
");
fprintf(stderr, "result: <plain>
");
fprintf(stderr, "result: <plain>\n");

Docs:
https://wiki.ubuntu.com/DashAsBinSh
echo:
Options to echo are not portable. In particular, the echo -e option is 
implemented by some shells, including bash, to expand escape sequences. 
However, dash is one of the other family of shells that instead expands escape 
sequences by default. Do not rely on either behaviour. If you need to print a 
string including any backslash characters, use the printf command instead, 
which is portable and much more reliable.

http://linux.die.net/man/1/dash
Single Quotes
2009-01-03 17:31:40 dinoex      Enclosing characters in single quotes preserves 
the literal meaning of all the characters (except single quotes, making it 
impossible to put single-quotes in a single-quoted string).

Problem: dash expands escape sequences even in Quoted text!
It is mentioned that the internal echo does auto-de-escaping for arguments.

According to:
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
2.2.2 Single-Quotes
2009-01-03 17:18:19 dinoex      Enclosing characters in single-quotes ( '' ) 
shall preserve the literal value of each character within the single-quotes. A 
single-quote cannot occur within single-quotes.

-- 
Fix /bin/sh
https://bugs.launchpad.net/bugs/313403
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to