Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if currently running shell is BusyBox

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
like image 475
svlasov Avatar asked Jul 22 '14 08:07

svlasov


1 Answers

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
like image 102
konsolebox Avatar answered Oct 27 '22 03:10

konsolebox