Date: Wed, 25 Oct 2006 01:45:31 -0700 From: Garrett Cooper <youshi10@u.washington.edu> To: freebsd-questions@freebsd.org Subject: Re: Bug with tcsh? : if evaluating true instead of false Message-ID: <453F242B.2060907@u.washington.edu> In-Reply-To: <453F05DC.6070906@u.washington.edu> References: <453F05DC.6070906@u.washington.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Garrett Cooper wrote: > Ok, so I tried to make a simple script to add users so I wouldn't have > to type in groups/pw over and over again... the problem is that it's not > behaving like it should =o. > > Script: > #!/bin/tcsh -x > # > > if ( ( $# != 0 ) ) { > > set GROUPS=""; > set USER=""; > > if( ( $# == 2 ) ) { > > set USER=$1; > set GROUPS=$0; > > switch($0) > > case "-v": > set GROUPS="-G vip"; > breaksw > > case "-w": > set GROUPS="-G vip,wheel"; > breaksw > default: > echo "bad argument(s) specified!"; > exit(1); > > endsw > > } else if($# == 1) { > set USER=$0; > } else { > echo "bad # of args; exiting.."; > } > > `pw add user -N -d /home/$USER -s /usr/local/bin/bash $GROUPS > $USER && mkdir /home/$USER && ln -s /home/dud.bash_login > /home/$USER/.bash_login`; > > } else { > print "Usage [-r|-v|-w] username" > } > > Output: > [root@hoover ~]# ./mkuser > if ( ( 0 != 0 ) ) { > set GROUPS= > set USER= > if ( ( 0 == 2 ) ) { > set USER= > set GROUPS=./mkuser > switch ( ./mkuser ) > echo bad argument(s) specified! > bad argument(s) specified! > exit ( 1 ) > > Basically it should drop out at the first if statement due to 0 != 0 > being true and go straight to the else block, but it's falling through > to the switch statement. Any ideas? > > Also.. > > [root@hoover /home/gcooper]# tcsh --version > tcsh 6.14.00 (Astron) 2005-03-25 (i386-intel-FreeBSD) options > wide,nls,dl,al,kan,rh,color,filec > > Thanks! > > -Garrett Duh... tcsh syntax != C/C++ or Java syntax. Silly me... lol. - -Garrett -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFPyQr6CkrZkzMC68RApumAJ9hl365xnqYknflDGr2Cc7O/UClnwCeN7Ih KsVQzm0ySuW3bSGe7cCgltQ= =MZO5 -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?453F242B.2060907>