threads / patch / 21008

patchTrivial fix: Display a more friendly message with git-shell.

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

## tl;dr

8 messages between Sep 20, 2009 and Sep 22, 2009. Diffs are folded; open one to read it.

replies: 7people: 6as markdown or json

Thiago Farina· Sep 20, 2009, 17:11 UTC · lore

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(-)
Show changes to shell.c +3 −1
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· Sep 21, 2009, 04:21 UTC · re: Thiago Farina · lore

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

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· Sep 21, 2009, 06:17 UTC · re: Thiago Farina · lore

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

Thiago Farina schrieb:
Show 11 quoted lines
> +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· Sep 21, 2009, 06:45 UTC · re: Johannes Sixt · lore

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

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· Sep 21, 2009, 20:45 UTC · re: Matthieu Moy · lore

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

Hi Matthieu On Mon, Sep 21, 2009 at 3:45 AM, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:

Show 6 quoted lines
> 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· Sep 22, 2009, 07:28 UTC · re: Thiago Farina · lore

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

Thiago Farina <tfransosi@gmail.com> writes:
Show 11 quoted lines
> 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· Sep 22, 2009, 08:15 UTC · re: Matthieu Moy · lore

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

On Tue, Sep 22, 2009 at 09:28:13AM +0200, Matthieu Moy wrote:
Show 13 quoted lines
> 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 ;)

Show changes to shell.c +2 −1
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· Sep 22, 2009, 08:17 UTC · re: Matthieu Moy · lore

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

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
Show 17 quoted lines
> 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

← back to recent threads