Article View: comp.unix.shell
Article #1081Re: bourne shell query
From: Scott Yelich
Date: Thu, 06 Sep 1990 16:08
Date: Thu, 06 Sep 1990 16:08
39 lines
2119 bytes
2119 bytes
>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@cs.odu.edu>
ODU/UNIX/BSD/X/C/ROOT/XANTH/CS/VSVN/
-----------------------------------------------------------------------------
Technical Details
Message-ID:
<SCOTT.90Sep6120809@tab00.larc.nasa.gov>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!abcfd20.larc.nasa.gov!tab00.larc.nasa.gov!scottReferences:
<75@iconsys> <925@hls0.hls.oz> <SCOTT.90Sep5124415@tab29.larc.nasa.gov> <1990Sep6.141133.3391@usenet.ins.cwru.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!abcfd20.larc.nasa.gov!tab00.larc.nasa.gov!scott From: scott@tab00.larc.nasa.gov (Scott Yelich) Newsgroups: comp.unix.shell Subject: Re: bourne shell query Message-ID: <SCOTT.90Sep6120809@tab00.larc.nasa.gov> Date: 6 Sep 90 16:08:09 GMT References: <75@iconsys> <925@hls0.hls.oz> <SCOTT.90Sep5124415@tab29.larc.nasa.gov> <1990Sep6.141133.3391@usenet.ins.cwru.edu> Sender: news@abcfd20.larc.nasa.gov (USENET File Owner) Organization: NASA Langley Research Center, Hampton, Va. 23665 Lines: 39 In-Reply-To: chet@cwns1.CWRU.EDU's message of 6 Sep 90 14:11:33 GMT