X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tests%2Flib.sh.test;h=3568c47de354f64e4dbfebd24fcf7ead4ee1ecb5;hb=3c9f2ee5ea8c7fe57864cad38f4f6188c569fa5d;hp=171c7c23ad583f21bf29f3c898fe7e628c230f17;hpb=f89f49df44d2d04eac338ead2d0843304414889e;p=config%2Fdotfiles.git diff --git a/tests/lib.sh.test b/tests/lib.sh.test index 171c7c2..3568c47 100644 --- a/tests/lib.sh.test +++ b/tests/lib.sh.test @@ -9,7 +9,7 @@ which() { echo /bin/ls else echo no doesnt-exist in /usr/bin /bin /usr/sbin /sbin - (exit 1) + return 1 fi } echo stdout which @@ -22,7 +22,7 @@ which() { echo /bin/ls else echo no doesnt-exist in /usr/bin /bin /usr/sbin /sbin >&2 - (exit 1) + return 1 fi } echo stderr which @@ -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.