evaluating ${10} and above in sh/ksh

Bob Desinger bd at hpopd.HP.COM
Wed Aug 15 01:35:15 AEST 1990


> There doesn't seem to be a way, in sh or ksh, to evaluate $10 and higher.

In /bin/sh this never worked, although individual vendors may have
modified their /bin/sh.  I don't know of any that have, by the way.

It looks like your ksh is broken.  Version 06/03/86 (or at least that
version shipped with HP-UX at 7.0 on Series 300 and 800) does the
right thing:

    set a b c d e f g h i j k l

    print 9 is $9, 10 is ${10}, 11 is ${11}, 12 is ${12}.

    alias i='echo Number 9'
    alias j='echo Number 10'
    alias k='echo Number 11'
    alias l='echo Number 12'
    eval $9
    eval ${10}
    eval ${11}
    eval ${12}
	
The new ksh88, Version 11/16/88, also does the right thing.  Both
versions of ksh generate the correct output:

    9 is i, 10 is j, 11 is k, 12 is l.
    Number 9
    Number 10
    Number 11
    Number 12

I invoked the script with `ksh script' and `ksh88 script'.   Then I
also tested it with a first line of `#! /usr/local/bin/ksh88' and
`#! /bin/ksh'.  All four cases generated the same output.  Uh, ksh88
isn't shipped with HP-UX; we bought it from the AT&T Toolchest.

Your script lines are considerably more complex than mine, though.  In
fact, I stopped trying to figure out what the script was trying to do
and just ran your script.  I mailed my output to you; we can follow
this up offline.  Summarize to the net?

-- bd



More information about the Comp.unix.wizards mailing list