How to get default shell?

I know that bash (if installed on OpenWrt) sets $SHELL. How can I find what the default shell is if it's ash? Should I assume it's ash if the $SHELL is empty/not set?

I'm going to source some user-configured files and I want to run the syntax check before sourcing them, but I want to make sure I'm running a syntax check with the correct shell.


On an install without modifying the shell, I see

1 Like

under bash $SHELL is still ash...

cat /proc/${PPID}/cmdline


Is it thru running env? What does echo "$SHELL" say? Sorry, I have no routers without bash at the moment.

Uhm, not for me:

EA8500 in ~ # echo $SHELL
EA8500 in ~ # env
echo $SHELL
1 Like
jeff@office:~$ echo $SHELL
jeff@office:~$ ls -l $(which sh)
lrwxrwxrwx    1 root     root             7 Jul 15 16:01 /bin/sh -> busybox
jeff@office:~$ ls -l $(which ash)
lrwxrwxrwx    1 root     root             7 Jul 15 16:01 /bin/ash -> busybox
jeff@office:~$ sh

BusyBox v1.31.0 () built-in shell (ash)

jeff@office:~$ exit
jeff@office:~$ ash

BusyBox v1.31.0 () built-in shell (ash)

1 Like

The default OpenWrt shell is BusyBox ash.
Neither the login shell from /etc/passwd nor the current shell from $SHELL are required to be the default.

Probably you shouldn't use sourcing if the code is not portable/compatible.
Verify the specific shell binary exists and invoke it either explicitly or via the shebang.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.