Skip to content

Commit

Permalink
[GUILT 5/6] Allow guilt scripts to be run from a directory which cont…
Browse files Browse the repository at this point in the history
…ains spaces

`dirname $0` breaks if $0 includes spaces.

I don't need this; it was the result of a mis-understanding.
But here it is anyway; take it if you think it's useful.

Signed-off-by: Alan Jenkins <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
  • Loading branch information
Alan Jenkins authored and jeffpc committed Mar 13, 2012
1 parent c043f1e commit ee5ccd7
Show file tree
Hide file tree
Showing 33 changed files with 45 additions and 41 deletions.
22 changes: 13 additions & 9 deletions guilt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
GUILT_VERSION="0.35"
GUILT_NAME="Gloria"

GUILT="$(basename "$0")"

# If the first argument is one of the below, display the man page instead of
# the rather silly and mostly useless usage string
case $1 in
-h|--h|--he|--hel|--help)
shift
exec "guilt help" "`basename $0`"
exec "guilt help" "$GUILT"
exit
;;
-V|--ver|--versi|--versio|--version)
Expand Down Expand Up @@ -69,10 +71,12 @@ silent()

########

GUILT_PATH="$(dirname "$0")"

guilt_commands()
{
find "`dirname $0`/../lib/guilt" -maxdepth 1 -name "guilt-*" -type f -perm +111 2> /dev/null | sed -e "s/.*\\/`basename $0`-//"
find "`dirname $0`" -maxdepth 1 -name "guilt-*" -type f -perm +111 | sed -e "s/.*\\/`basename $0`-//"
find "$GUILT_PATH/../lib/guilt" -maxdepth 1 -name "guilt-*" -type f -perm +111 2> /dev/null | sed -e "s/.*\\/$GUILT-//"
find "$GUILT_PATH" -maxdepth 1 -name "guilt-*" -type f -perm +111 | sed -e "s/.*\\/$GUILT-//"
}

# by default, we shouldn't fail
Expand All @@ -82,8 +86,8 @@ if [ $# -ne 0 ]; then
# take first arg, and try to execute it

arg="$1"
dir=`dirname $0`
libdir="`dirname $0`/../lib/guilt"
dir="$GUILT_PATH"
libdir="$GUILT_PATH/../lib/guilt"

if [ -x "$dir/guilt-$arg" ]; then
cmd="$dir/guilt-$arg"
Expand Down Expand Up @@ -878,10 +882,10 @@ pager="more"

UNAME_S=`uname -s`

if [ -r "`dirname $0`/os.$UNAME_S" ]; then
. "`dirname $0`/os.$UNAME_S"
elif [ -r "`dirname $0`/../lib/guilt/os.$UNAME_S" ]; then
. "`dirname $0`/../lib/guilt/os.$UNAME_S"
if [ -r "$GUILT_PATH/os.$UNAME_S" ]; then
. "$GUILT_PATH/os.$UNAME_S"
elif [ -r "$GUILT_PATH/../lib/guilt/os.$UNAME_S" ]; then
. "$GUILT_PATH/../lib/guilt/os.$UNAME_S"
else
die "Unsupported operating system: $UNAME_S"
fi
Expand Down
2 changes: 1 addition & 1 deletion guilt-add
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="<file>..."
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-applied
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-c]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-branch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[<new_name>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="-n <num> | -a | --all"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-delete
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-f] <patchname>"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-diff
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-z] [<path>...]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-export
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[<target_dir>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-files
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-v] [-a] [-l]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-fold
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-k] <patchname>"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-fork
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[<new_name>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-graph
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[<patchname>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-guard
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-l | --list | -n | --none | [<patchname>] [(+|-)<guard>...]]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-header
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-eE] [<patchname>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-help
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DO_NOT_CHECK_BRANCH_EXISTENCE=1

USAGE="[<command> | <topic>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-import
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-P <patch> ] <patch_file>"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-import-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[<hash> | <since>..[<until>] | ..<until>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-init
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DO_NOT_CHECK_BRANCH_EXISTENCE=1

USAGE=""
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-new
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-f] [-s] [-e|-m message] <patchname>"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-next
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-p|--path]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-patchbomb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DO_NOT_CHECK_BRANCH_EXISTENCE=1

USAGE="[-n] [-s] [--in-reply-to <msgid>] [--git] [--subject-prefix <prefix>] [<hash> | <since>..[<until>] | ..<until>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-pop
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-f] [-a | --all | -n <num> | <patchname>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-prev
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-p|--path]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-push
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[ -f ] [-a | --all | -n <num> | <patchname>]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-rebase
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

USAGE="<upstream>"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-refresh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[--git] [--diffstat]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-repair
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DO_NOT_CHECK_STATUS_FILE_FORMAT=1

USAGE="--full | --status"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-rm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="<file>..."
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-select
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[ -n | --none | -s | --series | [--pop|--reapply] <guards...> ]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-series
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-v | -g | -e]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-status
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-a|-A] [-c|-C] [-d|-D] [-m|-M] [-r|-R] [-t|-T] [-u|-U] [-x|-X] [-n]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-top
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE="[-p|--path]"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion guilt-unapplied
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

USAGE=""
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename $0` directly is no longer supported." >&2
echo "Invoking $GUILT directly is no longer supported." >&2
exit 1
fi

Expand Down

0 comments on commit ee5ccd7

Please sign in to comment.