bourne shell query

Scott Yelich scott at tab00.larc.nasa.gov
Fri Sep 7 02:08:09 AEST 1990


>cwns1$ foo -r -r
>test: too many arguments
>cwns1$ foo -r
>[: argument expected
> >4) eval ${1:+'echo "Yup!"'}

Right, if I am at all worried about a variable evr starting with a dash,
I do something as ugly as:
test "${var:+:}"

See, most ALL of my internal variables I SET and they will never be -something.
And if they ever get to be -something then the value is invalid.

>This *is* a nice way to test whether or not a variable is set.
I use it for cases when there MIGHT be a -something.

For instance, I have special routines which parse command line options.

>  Nobody seems to consider the case statement, which avoids these problems:
>	   "$2")	return 0
>	   *)	return 1

Yeah, perhaps test should just be smarter, but we can't wait for that.

>>Now, does anyone have and BOURNE SHELL (ie: /bin/sh) routines to do math?
>Well, the shell running as /bin/sh on my machine is bash, and it has
>$[] to do arithmetic substitution.

I am looking for ART styles here... not shell substitutions!  Arrraugh!

--
Signature follows. [Skip now]

 -----------------------------------------------------------------------------
 Scott D. Yelich                         scott@[xanth.]cs.odu.edu [128.82.8.1]
 After he pushed me off the cliff, he asked me, as I fell, ``Why'd you jump?''
 Administrator of:    Game-Design requests to <game-design-request at cs.odu.edu>
 ODU/UNIX/BSD/X/C/ROOT/XANTH/CS/VSVN/
 -----------------------------------------------------------------------------



More information about the Comp.unix.shell mailing list