maart@cs.vu.nl (Maarten Litmaath) (08/14/90)
In article <514@risky.Convergent.COM>, chrisb@risky.Convergent.COM (Chris Bertin) writes: )There doesn't seem to be a way, in sh or ksh, to evaluate $10 and higher. )$10 and higher are evaluated as ${1}0, ${1}1, etc... ) instead of ${10}, ${11}, etc... Alas... POSIX fixes this though: ${10} will work. )I have tried many different ways and they all fail. Do you know one )that will work? set a b c d e f g h i j k l m argv() { shift $1 2> /dev/null echo "$1" } echo `argv 10 "$@"` echo `argv 11 "$@"` echo `argv 20 "$@"` Beware of "$@": many shells will expand it to a single null string if there are no positional parameters present at all! A safe workaround is: ${1+"$@"} Check it out in the manual! -- "UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things." (Doug Gwyn)
mvadh@cbnews.att.com (andrew.d.hay) (08/14/90)
In article <514@risky.Convergent.COM>, chrisb@risky.Convergent.COM (Chris Bertin) writes: "There doesn't seem to be a way, in sh or ksh, to evaluate $10 and higher. "$10 and higher are evaluated as ${1}0, ${1}1, etc... " instead of ${10}, ${11}, etc... in ksh88, ${10}, ${11}, etc. are evaluated correctly, but YOU MUST BRACE THE ARGUMENTS! $10 and $11 are evaluated as you experienced. -- Andrew Hay +------------------------------------------------------+ Ragged Individualist | You just have _N_O idea! It's the difference | AT&T-BL Ward Hill MA | between _S_H_O_O_T_I_N_G a bullet and _T_H_R_O_W_I_N_G it! | a.d.hay@att.com +------------------------------------------------------+