Subject: Re: Trailing / in pathnames passed to build.sh
To: None <tech-toolchain@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-toolchain
Date: 08/17/2004 09:51:17
On Tue, 17 Aug 2004, Bang Jun-Young wrote:
> How about this:
> + [ ${OPTARG} != "/" ] && OPTARG="${OPTARG%/}"
That should work (modulo quoting "${OPTARG}"). However, I would do it
like this:
+# Convert possibly-relative path to absolute path by prepending
+# ${TOP} if necessary. Also delete trailing "/", if any.
resolvepath()
{
case "${OPTARG}" in
+ /)
+ ;;
/*)
+ OPTARG="${OPTARG%/}"
;;
+
*)
- OPTARG="${TOP}/${OPTARG}"
+ OPTARG="${TOP}/${OPTARG%/}"
;;
esac
}
--apb (Alan Barrett)