sh[it] and What am I missing here?

Brandon J. Wandersee brandon.wandersee at
Sun Jun 5 18:23:35 UTC 2016

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 at
::  --------------------------------------------------
::  'The best design is as little design as possible.'
::  --- Dieter Rams ----------------------------------

More information about the freebsd-questions mailing list