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

2 messages from 2014-11-24 to 2014-11-25. Participants: Dan Wyand, Junio C Hamano.
Thread: https://gitlist.dev/t/38039

## Dan Wyand, 2014-11-24 23:03

Subject: [PATCH] git-sh-setup.sh: use dashdash with basename call
Message-ID: <1416870211-13959-1-git-send-email-danwyand@gmail.com>
URL: https://gitlist.dev/e/1416870211-13959-1-git-send-email-danwyand%40gmail.com

```
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(-)

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, 2014-11-25 00:28

Subject: Re: [PATCH] git-sh-setup.sh: use dashdash with basename call
Message-ID: <xmqq3898unrx.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq3898unrx.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1416870211-13959-1-git-send-email-danwyand@gmail.com>

```
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).

>  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"
>  	}

```
