From owner-freebsd-questions@freebsd.org Sun Jun 5 18:23:34 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 DDC93B6B51C for ; Sun, 5 Jun 2016 18:23:34 +0000 (UTC) (envelope-from brandon.wandersee@gmail.com) Received: from mail-it0-f47.google.com (mail-it0-f47.google.com [209.85.214.47]) (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 B60C1166F for ; Sun, 5 Jun 2016 18:23:34 +0000 (UTC) (envelope-from brandon.wandersee@gmail.com) Received: by mail-it0-f47.google.com with SMTP id z189so27017009itg.0 for ; Sun, 05 Jun 2016 11:23:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=naa81+tD+BHcPsuqjKi7tC3TOSwtFLyJ2Uxtk6Bqbwk=; b=OVznI0le8EptEufdCZrzYtHFjpHf/Eg0AFE1LdqENX/eWw7dM23VsB+wabyh+cwZU8 6YXobNhfw/x3p6k2hoy7cb+XYxXkgOQjQQdQDWZhRSTnxf802DSXw0oJMJEeRFAqUBTL 1ywvSLY1NSRJYL5NVVcdXp1w0ehoemfbHW2vzq0kPYwDXVYr0z8EJ23QQJaY5EJupJ73 UYnCqtTR3s3kb9B3EkuppTxyre2SnOLtF4a8YLr9oD2KlPAZV4A2fKSu0QZdGZNiGOr6 rA0XYwd1QAlKNtAe1Xrhl2bK4ALkooCQ8ftGBrZ3SrCs1fbBtd2PkCom7gtiOfj0IBYA xMHw== X-Gm-Message-State: ALyK8tLSFX1S+gCmypJ42T3Vt8Q2kSlTL1TWJ5BOYf8bE721mOHNhUPQc2VxWFHUy9//Gg== X-Received: by 10.36.39.3 with SMTP id g3mr10678184ita.53.1465149156028; Sun, 05 Jun 2016 10:52:36 -0700 (PDT) Received: from WorkBox.Home.gmail.com (174-30-204-156.mpls.qwest.net. [174.30.204.156]) by smtp.gmail.com with ESMTPSA id r80sm4354562itc.18.2016.06.05.10.52.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Jun 2016 10:52:34 -0700 (PDT) References: <57544c10.90e58c0a.cacbc.62fd@mx.google.com> <57545029.5060805@gmail.com> <6f157455-0bda-ef46-82dc-e97fb0c4a08b@columbus.rr.com> User-agent: mu4e 0.9.16; emacs 24.5.1 From: Brandon J. Wandersee To: Baho Utot Cc: freebsd-questions@freebsd.org Subject: Re: sh[it] and What am I missing here? In-reply-to: <6f157455-0bda-ef46-82dc-e97fb0c4a08b@columbus.rr.com> Date: Sun, 05 Jun 2016 12:52:34 -0500 Message-ID: <86h9d7r09p.fsf@WorkBox.Home> MIME-Version: 1.0 Content-Type: text/plain 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:23:35 -0000 Baho Utot writes: > So here is what I tried. > Power on console ( boot computer ) > Login in as root > /bin/sh > > set # to show environment etc > WTF SHELL says I am in csh???? > > It should say SHELL=/bin/sh > > Hence my question here as to what is going on. It seems the $SHELL variable is derived from the settings for the account you log into. That variable persists when you run another shell, as (a) the base environment is inherited by child processes; and (b) the (interactive) shell is just another running user program at that point, not a base working environment itself. Log in as root and start a different (interactive) shell, and the variable will remain unchanged. Log in as a normal user and start another shell, and you'll get the same result. Log in as any user and `su` to any other user---simulating a new login---and the value of the variable will change to the user shell for the new account. As I understand it, you can have a script you've executed change the variable having it simulate a login shell and parse a custom configuration file. See the "Invocation" section of the sh(8) man page for an explanation. -- :: Brandon J. Wandersee :: brandon.wandersee@gmail.com :: -------------------------------------------------- :: 'The best design is as little design as possible.' :: --- Dieter Rams ----------------------------------