tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: interactive shell detection in shrc
On Mon, 30 Sep 2024, Greg A. Woods wrote:
SHELL is set by ksh and not by sh (sh handles NETBSD_SHELL), if I'm
not mistaken?
login(1) sets $SHELL, [...]
and also by programs which start a shell in a pty: xterm/script/tmux/...
However, xterm _doesn't_ set SHELL if what was passed is not in /etc/shells:
```
$ uname -a
Linux CoreBook 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/usr/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/usr/bin/dash
$ env SHELL=/bin/dash xterm -e 'printf ">%s<\n" "$SHELL"; read x'
```
On Mon, 30 Sep 2024, tlaronde%kergis.com@localhost wrote:
What I mean is that if I'm under ksh, and then I switch to sh even
explicitely setting interactive :
$ printenv
_=/usr/bin/printenv
...
SHELL=/bin/ksh
...
$ sh -i
$ printenv
...
SHELL=/bin/ksh
...
and the same result with "sh -l" (supposed to be considered a login
shell).
So how can the test be reliable in all circumstances?
Set SHELL explicitly?
```
$ echo $SHELL
/bin/bash
$ env SHELL=/bin/dash dash
$ echo $SHELL
/bin/dash
$
```
-RVP
Home |
Main Index |
Thread Index |
Old Index