From 8390d937cb3d642ddfcd2de1357e20703f7f7e9e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 21 Jul 2013 18:35:44 +1200 Subject: Cleaner argument count tests in cd function --- bash/bashrc.d/cd.bash | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'bash/bashrc.d/cd.bash') diff --git a/bash/bashrc.d/cd.bash b/bash/bashrc.d/cd.bash index a07f07b9..79e610d8 100644 --- a/bash/bashrc.d/cd.bash +++ b/bash/bashrc.d/cd.bash @@ -6,12 +6,10 @@ function cd { local opts="$opts -$opt" done shift $(($OPTIND-1)) - if [[ -n "$2" ]]; then + if [[ $# -eq 2 ]]; then builtin cd $opts "${PWD/$1/$2}" - elif [[ -n "$1" ]]; then - builtin cd $opts "$1" else - builtin cd $opts + builtin cd $opts "$@" fi } -- cgit v1.2.3