Subject: bug in build.sh
To: None <current-users@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: current-users
Date: 12/17/2001 14:22:41
I've spotted that src/build.sh won't run under the bourne shell!

This is due a subtle difference between 'sh' and 'ksh' etc that
affects the way:
	IFS=/
	set -- /fred//bill
handles initial separators and adjacent separaters.
The bourne shell will ignore initial, and merge adjacent ones.
ksh (and bash) will generate null strings.

build.sh uses the above in its mkdir() subroutine, and relies on
$1 being null to detect absolute paths.
Replacing:

# Emulate "mkdir -p" for systems that have an Old "mkdir".
mkdirp () {
        oifs=$IFS
        IFS=/; set -- $@; IFS=$oifs
        _d=
        if [ -z "$1" ]; then _d=/; shift; fi
with:
# Emulate "mkdir -p" for systems that have an Old "mkdir".
mkdirp () {
	_d=
	case "$1" in
	/* )        _d=/ ;;
	esac
        oifs="$IFS"
        IFS=/; set -- - $1; IFS="$oifs"
	shift

(Note that I'm more paranoid than the person who originally wrote this,
too many of my shell scripts have gone 'tits up' with unexpected args)

If you add 'set -- $*' before the 'shift', the 'if [ -n "$_f" ];' test
can
be removed from within the loop.

(I'm not trying to run this on a non netbsd system, I was just reading
the
script to see what it did......)

	David