Fix shell script path detection and check shell script error

This fixes use of `<spath>`, which does not return a file path when used inside a function.

What should happen when the script fails? Right now it just returns an empty list.