Subject: re: Trailing / in pathnames passed to build.sh
To: James Chacon <jmc@NetBSD.org>
From: matthew green <mrg@eterna.com.au>
List: tech-toolchain
Date: 08/17/2004 14:28:23
   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. $.

it's sane shell programming to quote stuff anyway.  it should be done.
   
   > 
   > 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.

build.sh requires a posix shell right?  this is posix sh functionality.