From owner-freebsd-questions@FreeBSD.ORG Wed Oct 25 06:36:28 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 AA02216A47B for ; Wed, 25 Oct 2006 06:36:28 +0000 (UTC) (envelope-from youshi10@u.washington.edu) Received: from mxout5.cac.washington.edu (mxout5.cac.washington.edu [140.142.32.135]) by mx1.FreeBSD.org (Postfix) with ESMTP id DCAA343D4C for ; Wed, 25 Oct 2006 06:36:27 +0000 (GMT) (envelope-from youshi10@u.washington.edu) Received: from smtp.washington.edu (smtp.washington.edu [140.142.33.9]) by mxout5.cac.washington.edu (8.13.7+UW06.06/8.13.7+UW06.09) with ESMTP id k9P6aRvD024976 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 24 Oct 2006 23:36:27 -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 k9P6aHpn001537 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 24 Oct 2006 23:36:24 -0700 Message-ID: <453F05DC.6070906@u.washington.edu> Date: Tue, 24 Oct 2006 23:36:12 -0700 From: Garrett Cooper User-Agent: Thunderbird 1.5.0.7 (X11/20060929) MIME-Version: 1.0 To: freebsd-questions@freebsd.org 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.24.232433 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: 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 06:36:28 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFPwXc6CkrZkzMC68RAo4sAJ9LOcJ6xnjTo2pWF8W6nOjqXqjfmACeP9OC WQWFzBpbKca+kkdT1APlo3k= =G6sT -----END PGP SIGNATURE-----