summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-02-27 23:34:23 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-02-27 23:34:23 -0500
commit73c4144faeea20c20ce7dfb977cd07077e82c0e3 (patch)
treea1acf8c889effa65866287c3cf56b72a52513505
parentb4aae66a7c3ba3eec714ca6cc11cd9913b5cf2fd (diff)
Fix 4 bugs in lb
1. Check if the command exists *and* is executable 2. Quote ${command} in case it contains whitespace, which would break syntax in the test (though, because it uses Bash builtin "[[" instead of the normal "/usr/bin/[", Bash *usually* recovers from this safely. 3. Go ahead and exit with an error if we print a fatal error message, don't keep running. 4. Put "$@" in quotes; it preserves whitespace in the arguments (while still keeping separate arguments separate).
-rwxr-xr-xlb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lb b/lb
index d4bd908..85fb4df 100755
--- a/lb
+++ b/lb
@@ -6,10 +6,11 @@ source /etc/libretools.conf
command=$1; shift
-[[ ! -f ~/l/libre${command} ]] && {
+[[ ! -x ~/l/libre"${command}" ]] && {
error "Command not found"
+ exit 1
}
-~/l/libre${command} $@
+~/l/libre${command} "$@"
exit $?