From owner-freebsd-questions@FreeBSD.ORG Wed Oct 25 08:45:47 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0A55B16A412 for ; Wed, 25 Oct 2006 08:45:47 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout4.cac.washington.edu (mxout4.cac.washington.edu [140.142.33.19]) by mx1.FreeBSD.org (Postfix) with ESMTP id 98C6843D5C for ; Wed, 25 Oct 2006 08:45:46 +0000 (GMT) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.33.7]) by mxout4.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW06.09) with ESMTP id k9P8jkpa028816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Oct 2006 01:45:46 -0700 X-Auth-Received: from [192.168.0.101] (dsl254-013-145.sea1.dsl.speakeasy.net [216.254.13.145]) (authenticated authid=youshi10) by smtp.washington.edu (8.13.7+UW06.06/8.13.7+UW06.09) with ESMTP id k9P8jc4w010397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 25 Oct 2006 01:45:43 -0700 Message-ID: <453F242B.2060907@u.washington.edu> Date: Wed, 25 Oct 2006 01:45:31 -0700 From: Garrett Cooper User-Agent: Thunderbird 1.5.0.7 (X11/20060929) MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <453F05DC.6070906@u.washington.edu> In-Reply-To: <453F05DC.6070906@u.washington.edu> X-Enigmail-Version: 0.94.1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-PMX-Version: 5.2.0.266434, Antispam-Engine: 2.4.0.264935, Antispam-Data: 2006.10.25.12933 X-Uwash-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __LINES_OF_YELLING 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __USER_AGENT 0' Subject: Re: Bug with tcsh? : if evaluating true instead of false X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2006 08:45:47 -0000 -----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-----