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
# 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
# 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
#! /bin/sh
-if [ -z "$1" -o -n "$2" ]; then
+if [ $# -ne 1 ]; then
echo "Usage: git open url_key" >&2
exit 1
-else
- url_key="$1"
fi
+url_key="$1"
if [ -z "$url_key" ]; then
echo "Usage: git open url_key" >&2
exit 1