diff --git a/fasd b/fasd index b1e64f4..6ffa254 100755 --- a/fasd +++ b/fasd @@ -577,7 +577,8 @@ fasd [-A|-D] [paths ...] local res res="$(fasd --query 2>> "$_FASD_SINK")" # query the database - [ $? -gt 0 ] && return + exitCode=$? + [ $exitCode -gt 0 ] && return $exitCode if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then res="$(printf %s\\n "$res" | sort -n${R} | \ sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')" diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..7183858 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,23 @@ +#!/bin/zsh + +fasd -f notARealFile.txt +failed=$? +fasd -f .vimrc +success=$? +fasd -d ~ +success_cd=$? + +if [[ $failed == 1 ]]; then + if [[ $success == 0 ]]; then + if [[ $success_cd == 0 ]]; then + echo Tests passed! + else + echo Error: ~ should have been found! + fi + else + echo Error: .vimrc should have been found! + fi +else + echo Error: notARealFile.txt should not have been found! +fi +