Subject: Re: Trailing / in pathnames passed to build.sh
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: James Chacon <jmc@NetBSD.org>
List: tech-toolchain
Date: 08/16/2004 14:32:13
On Mon, Aug 16, 2004 at 03:10:14PM -0400, der Mouse wrote:
> >> + OPTARG=`echo ${OPTARG} | sed -e 's/\/$//'`
> >> Any comments?
>
> > Looks good to me. (though I'll note s:/$:: works as well and avoids
> > an escape which tends to turn most sed expressions into line noise.)
>
> Well, it will break if $OPTARG contains shell metacharacters; should it
> maybe have " " in some places?
Unlikely...no matter the metacharacters it's just stripping off a trailing
/. Either that was there or it wasn't. There's no larger pattern space
to match/fail against since it's rooted against the end w. $.
>
> Also, is there some reason not to use OPTARG="${OPTARG%/}" instead? Is
> this one of the scripts that tries to stick to least-common-denominator
> capabilities and thus can't use the ${...%...} syntax?
Not all sh's support this correctly? The point w. build.sh is as portable
as possible.
James