Subject: Re: MAKEDEV is not portable
To: None <port-sparc@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: port-sparc
Date: 01/07/1999 13:20:05
In article <19990107101529.A19056@cc.ic.ac.uk> r.evans@ic.ac.uk (Robert Evans) writes:
>
>Yes, I must be missing something here, but doesn't sh still parse
>mkdisk_arith() when the function is defined?  E.g.
>

You need to be a bit trickier about it...

christos

#!/bin/sh
shellfeatures() {
	eval i=`(temp="xxx42"; echo ${temp#xxx}) 2> /dev/null`
	if [ "$i" = 42 ]; then
		eval 'mkdisk_arith() {
			mknod $1 b $2 $(($3 * 16 + $4))
		}'
		foo=arith
	else
		mkdisk_expr() {
		    mknod $1 b $2 `expr $3 \* 16 + $4`
		}
		foo=expr
	fi
}

shellfeatures

unit=0
maj=3

mkdisk_$foo sd${unit}c $maj $unit 2