diff --git a/bin/autojump.bash b/bin/autojump.bash index 46c3259..cc5d012 100644 --- a/bin/autojump.bash +++ b/bin/autojump.bash @@ -98,20 +98,26 @@ function jc { } function jo { - case ${OSTYPE} in - linux-gnu) - xdg-open "$(autojump $@)" - ;; - darwin*) - open "$(autojump $@)" - ;; - cygwin) - cmd /C start "" $(cygpath -w -a $(pwd)) - ;; - *) - echo "Unknown operating system." 1>&2 - ;; - esac + if [ -z $(autojump $@) ]; then + echo "autojump: directory '${@}' not found" + echo "Try \`autojump --help\` for more information." + false + else + case ${OSTYPE} in + linux-gnu) + xdg-open "$(autojump $@)" + ;; + darwin*) + open "$(autojump $@)" + ;; + cygwin) + cmd /C start "" $(cygpath -w -a $(pwd)) + ;; + *) + echo "Unknown operating system." 1>&2 + ;; + esac + fi } function jco { diff --git a/bin/autojump.zsh b/bin/autojump.zsh index d653867..9252934 100644 --- a/bin/autojump.zsh +++ b/bin/autojump.zsh @@ -62,20 +62,26 @@ function jc { } function jo { - case ${OSTYPE} in - linux-gnu) - xdg-open "$(autojump $@)" - ;; - darwin*) - open "$(autojump $@)" - ;; - cygwin) - cmd /C start "" $(cygpath -w -a $(pwd)) - ;; - *) - echo "Unknown operating system." 1>&2 - ;; - esac + if [ -z $(autojump $@) ]; then + echo "autojump: directory '${@}' not found" + echo "Try \`autojump --help\` for more information." + false + else + case ${OSTYPE} in + linux-gnu) + xdg-open "$(autojump $@)" + ;; + darwin*) + open "$(autojump $@)" + ;; + cygwin) + cmd /C start "" $(cygpath -w -a $(pwd)) + ;; + *) + echo "Unknown operating system." 1>&2 + ;; + esac + fi } function jco {