How to check if currently running shell is BusyBox
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
Personally I favour:
if ps ax -o pid,comm | grep `echo $$` | grep busybox ; then
echo "it is BusyBox"
fi
Which is a fair check to ensure you are running busybox shell.
This works by having ps generate a list of pids vs program names then finding our pid and checking if the program name contains busybox.