Re: shell compatibility issues with SunOS 5.10
- From
- Ralf Wildenhues <ralf.wildenhues@gmx.de>
- Date
- May 6, 2009, 09:19 UTC
- Message-ID
- <loom.20090506T091628-717@post.gmane.org>
- In-Reply-To
- <fcaeb9bf0905052357v6773cbf5i12795c1866a80783@mail.gmail.com>
Nguyen Thai Ngoc Duy writes:
Show 14 quoted lines
> On Wed, May 6, 2009 at 4:45 PM, Johannes Sixt wrote: > > Nguyen Thai Ngoc Duy schrieb: > >> # normalize path: > >> # multiple //; leading ./; /./; /../; trailing / > >> path=$(printf '%s/\n' "$path" | > >> sed -e ' > >> s|//*|/|g > >> s|^\(\./\)*|| > >> s|/\./|/|g > >> :start > >> s|\([^/]*\)/\.\./|| > >> tstart > >> s|/*$|| > >> ')
> It says nothing. The result of "printf '%s\n' ./foo/bar | sed -e blah" > is just wrong, (i.e. "./" remains). I stripped down to "sed -e > 's|^\(\./\)*||'", does not work. Probably due to \( \) pair. Skimmed > through sed manpage, seems no mention of bracket grouping.
Quoting 'info Autoconf "Limitation of Usual Tools"':
Some `sed' implementations, e.g., Solaris, restrict the special
role of the asterisk to one-character regular expressions. This
may lead to unexpected behavior: $ echo '1*23*4' | /usr/bin/sed 's/\(.\)*/x/g'
x2x4
$ echo '1*23*4' | /usr/xpg4/bin/sed 's/\(.\)*/x/g'
xYou can work around it in this case with :again s|^\./|| t again
BTW, you should put a space between t and the label (but not between : and label), POSIX requires that and some sed versions expect it.
Cheers, Ralf