delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/08/13/17:51:54

Date: Sun, 13 Aug 2000 14:51:06 -0700 (PDT)
From: Paul Eggert <eggert AT twinsun DOT com>
Message-Id: <200008132151.OAA05916@ruby.twinsun.com>
To: eliz AT is DOT elta DOT co DOT il
CC: meyering AT ascend DOT com, tr AT eth DOT net, djgpp-workers AT delorie DOT com,
autoconf AT gnu DOT org
In-reply-to: <Pine.SUN.3.91.1000813101728.21572B-100000@is>
(eliz AT is DOT elta DOT co DOT il)
Subject: Re: portability of sed's \{0,1\}?
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000813101728 DOT 21572B-100000 AT is>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

   Date: Sun, 13 Aug 2000 10:30:21 +0300 (IDT)
   From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>

   I don't see any work-arounds suggested for these problems.
   Does anyone know how do you express \(foo\)\{0,1\} portably?

There's no simple, general substitute for \(foo\)\{0,1\}, but you can
generally get the effect that you want by using multiple sed commands.
For example, here are two equivalent shell commands; the latter one
avoids the portability problem with \{0,1\}.

sed 's/^\([abcde]:\/\)\{0,1\}[^:]*: / /'
sed -e 's/^[abcde]:\/[^:]*: /: /' -e 's/^[^:]*: / /'

By the way, while testing these two commands, I discovered that the
former command does not work correctly with Solaris 8 /usr/bin/sed,
so Solaris 8 is another counterexample to the claim that \{0,1\} is
portable.  I'll write to the author of the sed FAQ about this.

- Raw text -


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