autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Clarify octal escapes with tr.


From: Eric Blake
Subject: [PATCH] Clarify octal escapes with tr.
Date: Mon, 26 Apr 2010 09:33:48 -0600

* doc/autoconf.texi (Limitations of Usual Tools): Carriage return
is portable in octal, but not newline.

Signed-off-by: Eric Blake <address@hidden>
---

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  <address@hidden>
+
+       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  <address@hidden>

        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
address@hidden 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
address@hidden 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
 $ @address@hidden echo moon; echo light; @} | /usr/ucb/tr -d '\n' ; echo}
@@ -18448,6 +18451,9 @@ Limitations of Usual Tools
 moonlight
 $ @address@hidden echo moon; echo light; @} | /usr/ucb/tr -d '\012' ; echo}
 moonlight
+$ @kbd{nl='}
address@hidden'; @{ 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]