Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been trying to find a bug in this test script, but haven't been able to so far. I'm not lazy, I promise...just new to Bash so am having a hard time catching syntax errors. I'd really appreciate it if someone could help me.

Here's the code. I call the script with the option -disableVenusBld, and it still prints "Starting build", which it shouldn't be doing right?

while [ $# -ne 0 ]
do
 arg="$1"
 case "$arg" in
  -disableVenusBld)
   disableVenusBld=true
   ;;
  -disableCopperBld)
   disableCopperBld=true
   ;;
  -disableTest)
   disableTest=true
   ;;
  -disableUpdate)
   disableUpdate=true
   ;;
  *)
   nothing="true"
   ;;
 esac
 shift
done

if [ "$disableVenusBld" != true ]; then
 echo "Starting build"
fi
share|improve this question
    
I just tried what you suggest and did not get Starting build when I supplied the -disableVenusBld flag. Can you give more information (i.e. system configuration, any output from the script when you run it, etc.) –  dtlussier Sep 9 '10 at 20:17
    
Ugh, typo on my part. I'm stupid like that lol. Thanks guys. –  iman453 Sep 9 '10 at 20:23

1 Answer 1

up vote 4 down vote accepted

I can't see anything wrong with your script, and it does what you expect when I run it:

$ bash -x 186724.sh
+ '[' 0 -ne 0 ']'
+ '[' '' '!=' true ']'
+ echo 'Starting build'
Starting build
$ bash -x 186724.sh -disableVenusBld
+ '[' 1 -ne 0 ']'
+ arg=-disableVenusBld
+ case "$arg" in
+ disableVenusBld=true
+ shift
+ '[' 0 -ne 0 ']'
+ '[' true '!=' true ']'

Note that I ran the script with bash -x. This causes all the lines beginning with + to be printed: you get a trace of the execution of your script. Do the same with your actual script to figure out where the problem is.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.