diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2014-10-14 18:12:10 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2014-10-14 18:12:10 +1300 |
commit | 89f6dd9a825df7723ba41045a8f305d50479cf83 (patch) | |
tree | 9e67f7b6fc3aeb90c70fd3851b0bcba4a1e4f669 /bash/bashrc.d/cd.bash | |
parent | Simplify cd wrapper (diff) | |
download | dotfiles-89f6dd9a825df7723ba41045a8f305d50479cf83.tar.gz dotfiles-89f6dd9a825df7723ba41045a8f305d50479cf83.zip |
Use case statement; cleaner
Diffstat (limited to 'bash/bashrc.d/cd.bash')
-rw-r--r-- | bash/bashrc.d/cd.bash | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/bash/bashrc.d/cd.bash b/bash/bashrc.d/cd.bash index 7a075657..a851752b 100644 --- a/bash/bashrc.d/cd.bash +++ b/bash/bashrc.d/cd.bash @@ -4,13 +4,19 @@ cd() { local arg local -a opts for arg in "$@" ; do - if [[ $arg == -- ]] ; then - shift - break - elif [[ $arg == -* ]] ; then - shift - opts=("${opts[@]}" "$arg") - fi + case $arg in + --) + shift + break + ;; + -*) + shift + opts=("${opts[@]}" "$arg") + ;; + *) + break + ;; + esac done if (($# == 2)) ; then if [[ $PWD == *"$1"* ]] ; then |