From owner-freebsd-questions@freebsd.org Sun Jun 5 18:26:51 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 AB221B6B5C9 for ; Sun, 5 Jun 2016 18:26:51 +0000 (UTC) (envelope-from jd1008@gmail.com) Received: from mail-it0-x233.google.com (mail-it0-x233.google.com [IPv6:2607:f8b0:4001:c0b::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 74CEF1744 for ; Sun, 5 Jun 2016 18:26:51 +0000 (UTC) (envelope-from jd1008@gmail.com) Received: by mail-it0-x233.google.com with SMTP id i65so20329694ith.1 for ; Sun, 05 Jun 2016 11:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-transfer-encoding; bh=sVf8cF8ScmWi2pxhgC5XiVB6ssMf4ORkVyOtANbOK9M=; b=Ctx6yKgME8WfOnMM65aUcozZE++fG1yJyibVZ+RbR3Fq/Kp1vmpb0VOOw1BK7Jlhca zqRT0KidfxDX7UjshnFqQLFSDsvVyZXw7UwHTK6eNS1eZ5bEXtNaTjVaQfE1cNpMZ5CA xATFpfF3vsYUwuCeCY8hKHEnl1WBgoZGnmf5AkOO6cyJn2UYgLlyn0Z+qDmNexhS2Ry3 QxSzuomG2bw4IznX1A/gnKuvwlp2q7odT8C9iZ6KDRgSCZAJaPuTkeVdT6gRI1eoYQ6N FkScBc8lV88/Lpd19NxDaLn5Zs5q0+xPtOXEJeovcv8ACRDKCSIigHedbZuPKDZzLABW 0CUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-transfer-encoding; bh=sVf8cF8ScmWi2pxhgC5XiVB6ssMf4ORkVyOtANbOK9M=; b=VAK6PLaCC3kIkkUoCiD/f3Hoh7NKR6IM7KLcoDyanZbH7nW6JyxRLdw9bXMpsKMM5t 3gdC5gnm0sGCeqCKOU03Xb0U8OmstI68mSJiwn1e9luWBsn2J/ZWzKDCKhnurIxm2pxz TJiGxBigagCIO4TiJWbpbnR4rO5sHyyLPysTXlvALM+Tx4LZ8GKGWOMbSt4rtYQAOP/q MhIidB09MdU7WqR9p2QZCjJRya7kQH+c+Y4sr+4q/8PAdBOsyd8itJgZKz7hws3magd4 CrGK21IVM4TlM21Uj9JUxCLrh7TZ3KDVkyVENIPcL+WHQvQMUAk1HWrrvV1EopoPeL2y lqKQ== X-Gm-Message-State: ALyK8tKButqrjFBpg4uycjHYRB2QDlXOc4hdyT3HfBrMLYL5ZMixvgkj8SIKJDTL8MBKlA== X-Received: by 10.36.82.72 with SMTP id d69mr11773595itb.3.1465151210744; Sun, 05 Jun 2016 11:26:50 -0700 (PDT) Received: from localhost.localdomain ([50.243.4.3]) by smtp.googlemail.com with ESMTPSA id v136sm4422617ita.3.2016.06.05.11.26.49 for (version=TLSv1/SSLv3 cipher=OTHER); Sun, 05 Jun 2016 11:26:49 -0700 (PDT) Message-ID: <57546ED4.2030700@gmail.com> Date: Sun, 05 Jun 2016 12:26:28 -0600 From: jd1008 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: sh[it] and What am I missing here? References: <31b2cfb1-1da8-9262-3f03-d964776c905e@columbus.rr.com> <575453F9.9070508@holgerdanske.com> <4daed7a2-9a0b-15d9-0bb2-31227f8fcddd@columbus.rr.com> <5754641A.8010508@gmail.com> In-Reply-To: <5754641A.8010508@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed 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 18:26:51 -0000 On 06/05/2016 11:40 AM, Ernie Luzar wrote: > 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: >> >> 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 > > I think your problem is where you are placing your script. > You have to place your script in a path that is auto searched for > executable scripts. > > Place your script in /usr/local/bin on your development pc and on the > new installed os pc. Then just entering the script on the console > command line will cause it to execute. BY the way your script doesn't > need to be suffixed with .sh to work. Hey Baho, Well, your login rc files (such as .cshrc or whatever other rc or profies files are executed, they set your default shell to (as you indicated) /bin/csh. Since you do not want to change that, then I suggest that your shell script you are working with have this code just after the shebang line: export SHELL=/bin/sh then code you functions and script after that. The shell variable value will only affect the shell you are executing and any other shell scripts you run from there (as long as those shell scripts are shebanged with #!/bin/sh and do not reset the SHELL variable value. HTH