www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/15/06:00:13

Date: Sun, 15 Nov 1998 12:35:20 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Ian Chapman <Ian DOT Chapman DOT ichapman AT nt DOT com>
cc: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: Re: Bash and sed
In-Reply-To: <915C65C50371D11187AD0000F881B9A401858D2A@bcarua62.ca.nortel.com>
Message-ID: <Pine.SUN.3.91.981115123425.1225B-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Thu, 12 Nov 1998, Ian Chapman wrote:

> 	The line ... A="`echo | tr '\012' '\001'`" ... is to ensure
> portability.  However what we have gives "unknown option to s".

``Portability'' my foot ;-).

This `tr' trick assumes that the empty line produced by `echo' holds a
single Newline character (octal code 012).  But on DOS and Windows,
`echo' outputs the CR-LF pair (\015\012) instead.  So after `tr' has
done its thing, A gets a string "\015\001", not a single character
001 as the script expects.

Here's a portable way to do this (should work on Unix as well):

       A="`echo | tr -s '\015\012' '\001\001'`"

The `-s' magic is described in the Textutils manual.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019