Carl Sorensen <[email protected]> writes:
> On 3/14/12 3:12 PM, "David Kastrup" <[email protected]> wrote:
>
>>
>>I backed it out of staging. Try again.
>
> Thanks, David. I guess if I figure out another fix, I'll have to try it
> on lilydev to make sure it works there as well as here.
Afraid so. bash has no problem with echo '\v', but dash, the default
/bin/sh in Ubuntu, cranks out a vertical tab.
And the MacOSX /bin/sh is the first shell I heard of that does not grok
echo -n.
Autoconf offers the following in "portable shell programming":
`echo'
The simple `echo' is probably the most surprising source of
portability troubles. It is not possible to use `echo' portably
unless both options and escape sequences are omitted. Don't
expect any option.
Do not use backslashes in the arguments, as there is no consensus
on their handling. For `echo '\n' | wc -l', the `sh' of Solaris
outputs 2, but Bash and Zsh (in `sh' emulation mode) output 1.
The problem is truly `echo': all the shells understand `'\n'' as
the string composed of a backslash and an `n'. Within a command
substitution, `echo 'string\c'' will mess up the internal state of
ksh88 on AIX 6.1 so that it will print the first character `s'
only, followed by a newline, and then entirely drop the output of
the next echo in a command substitution.
Because of these problems, do not pass a string containing
arbitrary characters to `echo'. For example, `echo "$foo"' is safe
only if you know that FOO's value cannot contain backslashes and
cannot start with `-'.
If this may not be true, `printf' is in general safer and easier
to use than `echo' and `echo -n'. Thus, scripts where portability
is not a major concern should use `printf '%s\n'' whenever `echo'
could fail, and similarly use `printf %s' instead of `echo -n'.
For portable shell scripts, instead, it is suggested to use a
here-document like this:
cat <<EOF
$foo
EOF
Alternatively, M4sh provides `AS_ECHO' and `AS_ECHO_N' macros
which choose between various portable implementations: `echo' or
`print' where they work, `printf' if it is available, or else
other creative tricks in order to work around the above problems.
The problem with a here-document is that it requires passing newlines
into the shell script, and that is something that Make does not care
for.
--
David Kastrup
_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel