Found this over on Stackoverflow
You could try running the script under Kornshell. When you execute a script with ksh -D
, it reads the commands and checks them for syntax, but doesn't execute them. Combine that with set -xv
, and you'll print out the commands that will be executed.
You can also use set -n
for the same effect. Kornshell and BASH are fairly compatible with each other. If it's a pure Bourne shell script, both Kornshell and BASH will execute it pretty much the same.
You can also run ksh -u
which will cause unset shell variables to cause the script to fail. However, that wouldn't have caught the catless cat of a nonexistent file. In that case, the shell variable was set. It was set to null.
Of course, you could run the script under a restricted shell too, but that's probably not going to uninstall the package.
That's the best you can probably do.