# [PATCH] Trivial fix: Display a more friendly message with git-shell.

8 messages from 2009-09-20 to 2009-09-22. Participants: Thiago Farina, Tay Ray Chuan, Johannes Sixt, Matthieu Moy, Heiko Voigt, Jakub Narebski.
Thread: https://gitlist.dev/t/21008

## Thiago Farina, 2009-09-20 17:11

Subject: [PATCH] Trivial fix: Display a more friendly message with git-shell.
Message-ID: <1253466672-21051-1-git-send-email-tfransosi@gmail.com>
URL: https://gitlist.dev/e/1253466672-21051-1-git-send-email-tfransosi%40gmail.com

```
Instead of simply die without give a helpful message, displays the usage
string that shows to the user how it can be used.

Signed-off-by: Thiago Farina <tfransosi@gmail.com>
---
 shell.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/shell.c b/shell.c
index e4864e0..aa7f47e 100644
--- a/shell.c
+++ b/shell.c
@@ -3,6 +3,8 @@
 #include "exec_cmd.h"
 #include "strbuf.h"
 
+static const char shell_usage[] = "git shell -c <command> <argument>";
+
 static int do_generic_cmd(const char *me, char *arg)
 {
 	const char *my_argv[4];
@@ -74,7 +76,7 @@ int main(int argc, char **argv)
 	 * where "cmd" is a very limited subset of git commands.
 	 */
 	else if (argc != 3 || strcmp(argv[1], "-c"))
-		die("What do you think I am? A shell?");
+		usage(shell_usage);
 
 	prog = argv[2];
 	if (!strncmp(prog, "git", 3) && isspace(prog[3]))
-- 
1.6.5.rc1.37.gf5c31.dirty

```

## Tay Ray Chuan, 2009-09-21 04:21

Subject: Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
Message-ID: <be6fef0d0909202121u1d7f843bx97f86eed8bf79618@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0909202121u1d7f843bx97f86eed8bf79618%40mail.gmail.com
In-Reply-To: <1253466672-21051-1-git-send-email-tfransosi@gmail.com>

```
Hi,

On Mon, Sep 21, 2009 at 1:11 AM, Thiago Farina <tfransosi@gmail.com> wrote:
> Instead of simply die without give a helpful message, displays the usage

s/give/giving/.

Not sure if the same should be done for die (like die()'ing).

-- 
Cheers,
Ray Chuan

```

## Johannes Sixt, 2009-09-21 06:17

Subject: Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
Message-ID: <4AB71A76.5010509@viscovery.net>
URL: https://gitlist.dev/e/4AB71A76.5010509%40viscovery.net
In-Reply-To: <1253466672-21051-1-git-send-email-tfransosi@gmail.com>

```
Thiago Farina schrieb:
> +static const char shell_usage[] = "git shell -c <command> <argument>";
> +
>  static int do_generic_cmd(const char *me, char *arg)
>  {
>  	const char *my_argv[4];
> @@ -74,7 +76,7 @@ int main(int argc, char **argv)
>  	 * where "cmd" is a very limited subset of git commands.
>  	 */
>  	else if (argc != 3 || strcmp(argv[1], "-c"))
> -		die("What do you think I am? A shell?");
> +		usage(shell_usage);

I don't think this is an improvement.

git-shell has a very limited use: It is to be used as the login-shell of
accounts where the admin will allow ssh access, but only to git repositories.

Every other use of git-shell is an error, and the current error message
says exactly that, although in a very 31337 way (and, BTW, /me likes it :-)

If an naive user runs git-shell from the command line, then your new
message will not be helpful because git-shell will accept only a very
restricted set of commands.

-- Hannes

```

## Matthieu Moy, 2009-09-21 06:45

Subject: Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
Message-ID: <vpqeiq0ssn7.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqeiq0ssn7.fsf%40bauges.imag.fr
In-Reply-To: <4AB71A76.5010509@viscovery.net>

```
Johannes Sixt <j.sixt@viscovery.net> writes:

> Every other use of git-shell is an error, and the current error message
> says exactly that, although in a very 31337 way (and, BTW, /me likes
> it :-)

Well, it's funny, but for a newcommer, trying "git shell" hoping to
get, for example what "bzr shell" gives (an interactive shell with
normal shell commands plus bzr ones without the 'bzr' prefix), it's
quite frustrating to be almost insulted by the tool for being curious.

> If an naive user runs git-shell from the command line, then your new
> message will not be helpful because git-shell will accept only a very
> restricted set of commands.

Perhaps one more line saying what 'man git-shell' says in addition
would help:

$ git-shell
git-shell: Restricted login shell for GIT-only SSH access
Usage: ...

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Thiago Farina, 2009-09-21 20:45

Subject: Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
Message-ID: <a4c8a6d00909211345q593e673bo4964204afa5ce807@mail.gmail.com>
URL: https://gitlist.dev/e/a4c8a6d00909211345q593e673bo4964204afa5ce807%40mail.gmail.com
In-Reply-To: <vpqeiq0ssn7.fsf@bauges.imag.fr>

```
Hi Matthieu
On Mon, Sep 21, 2009 at 3:45 AM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Perhaps one more line saying what 'man git-shell' says in addition
> would help:
>
> $ git-shell
> git-shell: Restricted login shell for GIT-only SSH access
> Usage: ...
I added this line to the output usage, but would be good to show the
commands that git-shell accept too?

```

## Matthieu Moy, 2009-09-22 07:28

Subject: Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
Message-ID: <vpqr5tzqvzm.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqr5tzqvzm.fsf%40bauges.imag.fr
In-Reply-To: <a4c8a6d00909211345q593e673bo4964204afa5ce807@mail.gmail.com>

```
Thiago Farina <tfransosi@gmail.com> writes:

> Hi Matthieu
> On Mon, Sep 21, 2009 at 3:45 AM, Matthieu Moy
> <Matthieu.Moy@grenoble-inp.fr> wrote:
>> Perhaps one more line saying what 'man git-shell' says in addition
>> would help:
>>
>> $ git-shell
>> git-shell: Restricted login shell for GIT-only SSH access
>> Usage: ...
> I added this line to the output usage, but would be good to show the
> commands that git-shell accept too?

Well, at some point, I think the user will have to read the man page.
I find it better to have a non-agressive error message, but I'm not
sure it's relevant to try to give the complete manual here.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Heiko Voigt, 2009-09-22 08:15

Subject: Re: Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
Message-ID: <20090922081544.GB48307@book.hvoigt.net>
URL: https://gitlist.dev/e/20090922081544.GB48307%40book.hvoigt.net
In-Reply-To: <vpqr5tzqvzm.fsf@bauges.imag.fr>

```
On Tue, Sep 22, 2009 at 09:28:13AM +0200, Matthieu Moy wrote:
> Thiago Farina <tfransosi@gmail.com> writes:
> 
> > On Mon, Sep 21, 2009 at 3:45 AM, Matthieu Moy
> > <Matthieu.Moy@grenoble-inp.fr> wrote:
> >> $ git-shell
> >> git-shell: Restricted login shell for GIT-only SSH access
> >> Usage: ...
> > I added this line to the output usage, but would be good to show the
> > commands that git-shell accept too?
> 
> Well, at some point, I think the user will have to read the man page.
> I find it better to have a non-agressive error message, but I'm not
> sure it's relevant to try to give the complete manual here.

Why not simply like this? I liked the old output as well. And sometimes its
just better to have commands behave like humans ;)

diff --git a/shell.c b/shell.c
index e4864e0..a0da191 100644
--- a/shell.c
+++ b/shell.c
@@ -74,7 +74,8 @@ int main(int argc, char **argv)
         * where "cmd" is a very limited subset of git commands.
         */
        else if (argc != 3 || strcmp(argv[1], "-c"))
-               die("What do you think I am? A shell?");
+               die("What do you think I am? A shell?\n\
+                    See: git help shell");
 
        prog = argv[2];
        if (!strncmp(prog, "git", 3) && isspace(prog[3]))

```

## Jakub Narebski, 2009-09-22 08:17

Subject: Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
Message-ID: <m3fxafbdh0.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3fxafbdh0.fsf%40localhost.localdomain
In-Reply-To: <vpqr5tzqvzm.fsf@bauges.imag.fr>

```
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
> Thiago Farina <tfransosi@gmail.com> writes:
> 
>> Hi Matthieu
>> On Mon, Sep 21, 2009 at 3:45 AM, Matthieu Moy
>> <Matthieu.Moy@grenoble-inp.fr> wrote:
>>> Perhaps one more line saying what 'man git-shell' says in addition
>>> would help:
>>>
>>> $ git-shell
>>> git-shell: Restricted login shell for GIT-only SSH access
>>> Usage: ...
>> I added this line to the output usage, but would be good to show the
>> commands that git-shell accept too?
> 
> Well, at some point, I think the user will have to read the man page.
> I find it better to have a non-agressive error message, but I'm not
> sure it's relevant to try to give the complete manual here.

Perhaps:

  $ git-shell
  git-shell: Restricted login shell for GIT-only SSH access
  This shell cannot be used as a login (interactive) shell

and/or

  $ ssh user@repo.example.com
  This user is restricted to GIT-only SSH access

(or something like that, especially in the second case).

I don't think giving 'Usage:' here would be a good idea, as this
program is not meant for end user, but for automatic use.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```
