threads / patch / 38039

patchgit-sh-setup.sh: use dashdash with basename call

Subject: [PATCH] git-sh-setup.sh: use dashdash with basename call

## tl;dr

2 messages between Nov 24, 2014 and Nov 25, 2014. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Dan Wyand· Nov 24, 2014, 23:03 UTC · lore
Calling basename on a argument that starts with a dash, like a login shell,
will result in an error. This patch adds '--' before the argument so that the
argument is interpreted properly.
---
 git-sh-setup.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to git-sh-setup.sh +1 −1
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 9447980..5cdae33 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -81,7 +81,7 @@ if test -n "$OPTIONS_SPEC"; then
 		echo exit $?
 	)"
 else
-	dashless=$(basename "$0" | sed -e 's/-/ /')
+	dashless=$(basename -- "$0" | sed -e 's/-/ /')
 	usage() {
 		die "usage: $dashless $USAGE"
 	}
-- 
2.1.3
Junio C Hamano· Nov 25, 2014, 00:28 UTC · re: Dan Wyand · lore

Re: [PATCH] git-sh-setup.sh: use dashdash with basename call

Dan Wyand <danwyand@gmail.com> writes:
> Calling basename on a argument that starts with a dash, like a login shell,
> will result in an error. This patch adds '--' before the argument so that the
> argument is interpreted properly.
> ---
Makes sense.
Please sign-off your patch (see Documentation/SubmittingPatches).
Show 16 quoted lines
>  git-sh-setup.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-sh-setup.sh b/git-sh-setup.sh
> index 9447980..5cdae33 100644
> --- a/git-sh-setup.sh
> +++ b/git-sh-setup.sh
> @@ -81,7 +81,7 @@ if test -n "$OPTIONS_SPEC"; then
>  		echo exit $?
>  	)"
>  else
> -	dashless=$(basename "$0" | sed -e 's/-/ /')
> +	dashless=$(basename -- "$0" | sed -e 's/-/ /')
>  	usage() {
>  		die "usage: $dashless $USAGE"
>  	}

← back to recent threads