* doc/autoconf.texi (Limitations of Usual Tools): Carriage return is portable in octal, but not newline.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- Steve's comments made me re-evaluate our existing text for tr portability. We've already proved that raw carriage returns in scripts is a portability disaster, but thankfully, both ASCII and EBCDIC encode carriage return as the same byte. But since newline is encoded differently, our text should document that it can be even more portable to use a literal newline. ChangeLog | 6 ++++++ doc/autoconf.texi | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3947cb1..7dda7ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-26 Eric Blake <ebl...@redhat.com> + + Clarify octal escapes with tr. + * doc/autoconf.texi (Limitations of Usual Tools): Carriage return + is portable in octal, but not newline. + 2010-02-25 Eric Blake <ebl...@redhat.com> Properly quote AC_PREREQ during autoupdate. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 3f88670..e410468 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -18432,13 +18432,16 @@ Limitations of Usual Tools @c --------------- @prindex @command{tr} @cindex carriage return, deleting +...@cindex newline, deleting @cindex deleting carriage return Not all versions of @command{tr} handle all backslash character escapes. For example, Solaris 10 @command{/usr/ucb/tr} falls over, even though Solaris contains more modern @command{tr} in other locations. -Therefore, it is more portable to use octal escapes, even though this -ties the result to ASCII, when using @command{tr} to delete -newlines or carriage returns. +Using octal escapes is more portable for carriage returns, since +...@samp{\015} is the same for both ASCII and EBCDIC, and since use of +literal carriage returns in scripts causes a number of other problems. +But for other characters, like newline, using octal escapes ties the +operation to ASCII, so it is better to use literal characters. @example $ @k...@{ echo moon; echo light; @} | /usr/ucb/tr -d '\n' ; echo} @@ -18448,6 +18451,9 @@ Limitations of Usual Tools moonlight $ @k...@{ echo moon; echo light; @} | /usr/ucb/tr -d '\012' ; echo} moonlight +$ @kbd{nl='} +...@kbd{'; @{ echo moon; echo light; @} | /usr/ucb/tr -d "$nl" ; echo} +moonlight @end example Not all versions of @command{tr} recognize ranges of characters: at -- 1.6.6.1