X-Git-Url: https://git.phdru.name/?p=dotfiles.git;a=blobdiff_plain;f=.shellrc;h=0677d0e7f11407883a0552b386fb7dff5eeab0b8;hp=205f870cb6d00d2b1de10f62eeda371cf74c7e74;hb=26a977f44877d9dead5e1f6e0374b4501688e145;hpb=b519e7b6fb559b7946cc6758b4712d16980b7341 diff --git a/.shellrc b/.shellrc index 205f870..0677d0e 100644 --- a/.shellrc +++ b/.shellrc @@ -188,13 +188,12 @@ chlo() { clear; cd; >$HISTFILE; unset HISTFILE; history -c; logout || exit; } if test -x /usr/bin/git >/dev/null 2>&1; then # chdir to a directory cdgitpath() { - if [ -z "$1" -o -n "$2" ]; then + if [ $# -ne 1 ]; then echo "Usage: cdgitpath path_key" >&2 return 1 - else - path_key="$1" fi + path_key="$1" if [ -z "$path_key" ]; then echo "Usage: cdgitpath path_key" >&2 return 1 @@ -205,12 +204,14 @@ if test -x /usr/bin/git >/dev/null 2>&1; then # chdir to a remote's directory (if the remote is on the local FS) cdremote() { + if [ $# -gt 1 ]; then + echo "Usage: cdremote [remote_name]" >&2 + return 1 + fi + if [ -z "$1" ]; then branch="`git rev-parse --abbrev-ref HEAD`" remote="`git config --get branch.$branch.remote`" - elif [ -n "$2" ]; then - echo "Usage: cdremote [remote_name]" >&2 - return 1 else remote="$1" fi @@ -278,7 +279,7 @@ if test -x /usr/bin/git >/dev/null 2>&1; then # list remotes with URLs matching a regexp _list_remotes() { - if [ -z "$1" -o -n "$2" ]; then + if [ $# -ne 1 ]; then echo "Usage: _list_remotes remote_regexp" >&2 return 1 fi