My apologies as this has to be a question others have asked but it seems google proof. I'm trying to figure out what shell is being invoked as I have met an inconsistency. My script doesn't work if I sudo
, but does work if I sudo bash
. Yet when I sudo echo $0
, it says bash.
cpu=$(cat /proc/cpuinfo | grep Revision | cut -d' ' -f 2-);
if [[ "a22082" = $cpu || "a02082" = $cpu ]]; then
echo 'do stuff';
fi
If I specify the command interpreter with #!/bin/sh it still fails but being more specific #!/bin/bash it does.
I (now) know that [[
is bash specific but despite the response it doesn't seem like sudo's default shell is bash.