This doesn't really answer your question but skimming your email I assume you are trying to process command line options in bash scripts and so I'm wondering if you have considered using getopt or getopts to process your command line options instead? getopt is actually the older and "less good" way to do things but it's the one I use because I'm more familiar with it. The code below is a "getopt" example but if you google for "bash getopt" you will find much better examples of both getopt and getopts. ----- (beware of wrapping!) ----- useage () { echo " Useage: `basename $0` [-as] [-c FILE] [-i IP[:PORT]] [-u USERID] <DOMAIN> <DIRROOT> exit 1 } set -- `getopt "asc:u:g:i:" "$@"` || { useage exit 1 } while : do case "$1" in -a) # echo "option alias"; CALIAS=YES;; -s) # echo "option scripts"; SCRIPTS=YES;; -u) # echo "option userid"; shift; EMAILUSER="$1"; USERID="$1";; -g) # echo "option userid"; shift; GROUP="$1";; -c) # echo "option config"; shift; CONFIG="$1";; -i) # echo "option ip"; shift; IP="$1";; --) # echo "option --"; break;; esac shift done shift ----- -- John Lange www.johnlange.ca On Fri, 2008-11-14 at 22:54 -0600, David C. Rankin wrote:
Listmates,
Stuck on a stupid bash problem again. Why can't I set a variable within a set of parenthesis?
#!/bin/bash
# This works
[[ $1 == "--verbose" || $1 == "-v" ]] && verbose='y'
[[ $1 == "--verbose" || $1 == "-v" ]] && ( echo "this"; echo "that" )
# This _doesn't_ work
[[ $1 == "--verbose" || $1 == "-v" ]] && ( verbose='y'; echo "that" )
No matter what I do, if I try to set a variable inside the ( ) expression, it never gets set -- Why?
-- David C. Rankin, J.D.,P.E. | Rankin Law Firm, PLLC | Countdown for openSuSE 11.1 510 Ochiltree Street | http://counter.opensuse.org/11.1/small Nacogdoches, Texas 75961 | Telephone: (936) 715-9333 | openSoftware und SystemEntwicklung Facsimile: (936) 715-9339 | http://www.opensuse.org/ www.rankinlawfirm.com |
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org