]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - tests/lib.sh.test
lib.sh: Fix installed() for which with no output in case of error.
[config/dotfiles.git] / tests / lib.sh.test
index e8d5053be6ebec71118818ad1c3a7505b0787525..3568c47de354f64e4dbfebd24fcf7ead4ee1ecb5 100644 (file)
@@ -41,6 +41,18 @@ echo stupid which
 installed ls && echo ls installed
 installed doesnt-exist && echo doesnt-exist installed
 
+# which with proper exit codes and no output in case of an error.
+which() {
+    if [ $1 = ls ]; then
+        echo /bin/ls
+    else
+        return 1
+    fi
+}
+echo different which
+installed ls && echo ls installed
+installed doesnt-exist && echo doesnt-exist installed
+
 
 # Tests for generate().
 echo "Simple test file for generate() using m4.