The primary issue was that [ ! -d $UNDEFVAR ] is always false, meaning that
$TOP wouldn't be set. I've adjusted the conditional and also taken the
opportunity to ensure that all arguments to [ are quoted, to avoid issues in
the cases the directory contains a space. Additionally, I've reformatted the
opensocdebug related lines to use more conventional indentation which matches
the rest of the file.
As discussed, I've now avoided quoting shell variables, as this would only fix issues in this script but would lead to other less obvious problems down the line. Please re-review, I've edited and re-pushed.
The primary issue was that
[ ! -d $UNDEFVAR ]
is always false, meaning that $TOP wouldn't be set. I've adjusted the conditional and also taken the opportunity to ensure that all arguments to[
are quoted, to avoid issues in the cases the directory contains a space. Additionally, I've reformatted the opensocdebug related lines to use more conventional indentation which matches the rest of the file.