From owner-freebsd-questions@freebsd.org Sun Jun 5 23:01:17 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5B68FB6B8E9 for ; Sun, 5 Jun 2016 23:01:17 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EB7F4124E for ; Sun, 5 Jun 2016 23:01:16 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: by mail-wm0-x233.google.com with SMTP id m124so50648317wme.1 for ; Sun, 05 Jun 2016 16:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PEg28ua9Ccfoj8tM2pJ+Cvqc4BU20xnmbVD3NZ5cZVE=; b=osZqQaaRhKWXk94rScwTvVB/G5nsh1KLgUB1MNeICvPPfSNRPkD7taxbDj+0eZsnyI B/GR3YVNpUn6cEwsliqUBTvd+THuqnsWy9U73bHo6+K1K8n/oCGMLokAv7JXkC8fypkY HzN8vOGqwzEdv7Wk2n6J6T7l/1QX5TWje8YmdLPISDQCiRG1GfbDO3DD7+gynhASbGk4 JltLOIpcbwg8//qWfsax4SMFtDU6cPSxXo+HKZRhBk3CutGowTqdfwit0j8Dp71XCjp2 wBjlTg4H3aC0P4g6/7R6U0CMomjbopXC3V0C18g4UKZ2EyNEqNGRdG3A3dD7aQajejWJ pK7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PEg28ua9Ccfoj8tM2pJ+Cvqc4BU20xnmbVD3NZ5cZVE=; b=mG6u2srgcYyQIdeFh4B2EwiqLLTV8UfNY6xEnIHEk6IAr8KbNgmIyv5HW8dU/Aq5ML 1ymb2JeASehePUz5sAUKuV7gRmdJumy0TTlTKGcl8T2t4CQ8Jjaz8brKMLx90+QKULiu H7mkVksqxBn8sr+iHMrHQgWtnidtR7BdjSld4EFyIpDD8TbI/Cn7cH63UhfwSPHz14pp FrIRvAfWUPNaS35Eyk9tW3cvdus0x2P9zi3OFHKpmbVWzFc5N7Oaq0ahBSg+OxxCrhS8 aewk8wn5LTlBWfQTzZKD3EZtg1mP4eTDkzhQs+RnftJrntw6aRIKFhX+HYJmeaCn+2AQ r5PA== X-Gm-Message-State: ALyK8tLsvo+z2smCirxUtMGk4/8GX/31fRIdDG3aBMtrD1m4lc8LgbRJCtCOOsfWDMNmIg== X-Received: by 10.194.246.38 with SMTP id xt6mr12238984wjc.44.1465167674917; Sun, 05 Jun 2016 16:01:14 -0700 (PDT) Received: from gumby.homeunix.com ([81.171.97.158]) by smtp.gmail.com with ESMTPSA id lr9sm17195342wjb.39.2016.06.05.16.01.11 for (version=TLSv1/SSLv3 cipher=OTHER); Sun, 05 Jun 2016 16:01:13 -0700 (PDT) Date: Mon, 6 Jun 2016 00:01:09 +0100 From: RW To: freebsd-questions@freebsd.org Subject: Re: sh[it] and What am I missing here? Message-ID: <20160606000109.3141550d@gumby.homeunix.com> In-Reply-To: <4daed7a2-9a0b-15d9-0bb2-31227f8fcddd@columbus.rr.com> References: <31b2cfb1-1da8-9262-3f03-d964776c905e@columbus.rr.com> <575453F9.9070508@holgerdanske.com> <4daed7a2-9a0b-15d9-0bb2-31227f8fcddd@columbus.rr.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; amd64-portbld-freebsd10.2) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jun 2016 23:01:17 -0000 On Sun, 5 Jun 2016 13:15:25 -0400 Baho Utot wrote: > On 06/05/16 12:31, David Christensen wrote: > > On 06/05/2016 08:38 AM, Baho Utot wrote: > > ... > >> root@baho-utot:~ # set > > ... > >> shell /bin/csh > > ... > >> tcsh 6.18.01 > > ... > >> OK tcsh as I thought > > ... > >> OK switch shells > >> > >> root@baho-utot:~ # /bin/sh > >> # set > > ... > >> Why is the SHELL variable still set to /bin/csh > > ... > > > > Because you are invoking a program (/bin/sh) and that program did > > not modify the SHELL environment variable. > > > > > > On 06/05/2016 09:15 AM, jd1008 wrote: > > > Do I understand correctly that you want bash to be your shell? > > > If so, you can run (as root), the command > > > chsh > > > > +1 > > > > Take a look at: > > > > https://www.freebsd.org/doc/en/articles/linux-users/shells.html > > > > > > David > > I understood that, But I do not want to change the default shell. > I only want to create a script ( sh script ) and run if from a clean > machine with just base install nothing else and then run my sh script > to build some ports. That's were the trouble lies. ie functions not > returning status for example: It doesn't work because the shell script is wrong. [ func ] doesn't execute func. func and "]" are actually arguments to "[". Using backticks around func executes it. See man test for the rest. $ cat /tmp/foo #!/bin/sh func() { echo "Yep its me" return 1 } if ! func ; then echo "This works" fi if [ "`func`" = "Yep its me" ] ; then echo "This works too" fi if [ "`func`" ] ; then echo "And this works also" fi $ /tmp/foo Yep its me This works This works too And this works also > test.sh > chmod +x test.sh > > #!/bin/sh > > func() { > echo "Yep it's me" > return 1 > } > > if [ func ] ; then # if [ 1 = func ] or if [ 1 -eq > func ] doesn't work either > echo "This works" > fi > > ./test.sh > > [: func: unexpected operator > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org"