Subject: Re: Trailing / in pathnames passed to build.sh
To: None <tech-toolchain@NetBSD.org>
From: Bang Jun-Young <junyoung@mogua.com>
List: tech-toolchain
Date: 08/17/2004 10:35:48
Alan Barrett wrote:
> On Tue, 17 Aug 2004, Bang Jun-Young wrote:
> > --- build.sh    6 Feb 2004 23:19:30 -0000       1.127
> > +++ build.sh    16 Aug 2004 18:40:20 -0000
> > @@ -324,6 +324,7 @@
> > 
> >  resolvepath()
> >  {
> > +       OPTARG=`echo ${OPTARG} | sed -e 's/\/$//'`
> >         case "${OPTARG}" in
> >         /*)
> >                 ;;
> > 
> > Any comments?
> 
> * You probably can't rely on a working sed being available so early in
>   the build process.
> * The arg passed to echo is not properly quoted.
> * The result of the backtick substitution is not properly quoted.
> * It would be so much easier to avoid all the above problems by using
>   OPTARG="${OPTARG%/}".  build.sh already requires a working POSIX shell,
>   so (in answer to der Mouse's question in another message) there's no
>   problem with ${variable%pattern} substitution.
> 
> * What is the expected behaviour when OPTARG="/"?  It probably needs to
>   be treated as a special case, so that it is not converted to
>   OPTARG="".

How about this:

--- build.sh    6 Feb 2004 23:19:30 -0000       1.127
+++ build.sh    17 Aug 2004 01:32:28 -0000
@@ -324,6 +324,7 @@

 resolvepath()
 {
+       [ ${OPTARG} != "/" ] && OPTARG="${OPTARG%/}"
        case "${OPTARG}" in
        /*)
                ;;

Jun-Young