Cameron Simpson wrote:
>So you will find
>
> ${1+"$@"}
>
>in portable wrapper scripts.
>
>Aside: ${1:+"$@"} is wrong wrong wrong. As an exercise, tell me what it would
> break.
Hmm ... the latter construct would allow a null argument. So to
demonstrate to myself how the behavior would differ, I created
args.sh:
#!/bin/bash
good=${1+"$@"}
bad=${1:+"$@"}
if [ -n "$good" ]; then echo "Good: $good"; fi
if [ -n "$bad" ] ;then echo "Bad: $bad"; fi
Then invoked it like this:
./args.sh "" one two
And lo, it did beget this:
Good: one two
Which is interesting, and means that in the latter case, if the first
argument to the function happens to be null, they ALL get deep-sixed.
Thanks for the tip (and the challenge)!
-d
--
David Talkington
Prairienet / Community Networking Initiative
217-244-1962
[EMAIL PROTECTED]
PGP key: http://www.prairienet.org/~dtalk/dt000823.asc
_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list
- Re: Best backup system/plan for max... Bill Anderson
- Re: Best backup system/plan for... rpjday
- Re: Best backup system/plan for... Jonathan Wilson
- Re: Best backup system/plan for... rpjday
- Re: Best backup system/plan for... Cameron Simpson
- Re[2]: Best backup system/plan ... Brian Ashe
- Re: Best backup system/plan for... Bret Hughes
- Re: Best backup system/plan for... Cameron Simpson
- Re: Best backup system/plan for... David Talkington
- Re: Best backup system/plan for... Cameron Simpson
- Re: Best backup system/plan for... David Talkington
- Re: Best backup system/plan for... Greg Wright
- Re: Best backup system/plan for... David Talkington
- Re: Best backup system/plan for... Cameron Simpson
- Re: Best backup system/plan for... Bret Hughes
- Re: Best backup system/plan for... Cameron Simpson
- Re: Best backup system/plan for... Bill Anderson
- Re: Best backup system/plan for... rpjday
- Re: Best backup system/plan for maximum safety - what do ... Bill Carlson
- RE: Best backup system/plan for maximum safety - what do ... Kevin Thorpe
