I tried different variants
echo $0 echo $shell echo $SHELL ps -p $$
but none of them can give a distinctive output. I can do something like this but it’s ugly and hackish:
if ls --help 2>&1 | grep BusyBox; then echo "it is BusyBox" else echo "it is NOT BusyBox" fi
Advertisement
Answer
Another way requiring Linux and readlink
:
#!/bin/ash exe=`exec 2>/dev/null; readlink "/proc/$$/exe"` case "$exe" in */busybox) echo "It's a busybox shell." ;; esac