git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Trivial fix: Display a more friendly message with git-shell.
@ 2009-09-20 17:11 Thiago Farina
  2009-09-21  4:21 ` Tay Ray Chuan
  2009-09-21  6:17 ` Johannes Sixt
  0 siblings, 2 replies; 8+ messages in thread
From: Thiago Farina @ 2009-09-20 17:11 UTC (permalink / raw)
  To: git; +Cc: Thiago Farina

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Trivial fix: Display a more friendly message with  git-shell.
  2009-09-20 17:11 [PATCH] Trivial fix: Display a more friendly message with git-shell Thiago Farina
@ 2009-09-21  4:21 ` Tay Ray Chuan
  2009-09-21  6:17 ` Johannes Sixt
  1 sibling, 0 replies; 8+ messages in thread
From: Tay Ray Chuan @ 2009-09-21  4:21 UTC (permalink / raw)
  To: Thiago Farina; +Cc: git

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
  2009-09-20 17:11 [PATCH] Trivial fix: Display a more friendly message with git-shell Thiago Farina
  2009-09-21  4:21 ` Tay Ray Chuan
@ 2009-09-21  6:17 ` Johannes Sixt
  2009-09-21  6:45   ` Matthieu Moy
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Sixt @ 2009-09-21  6:17 UTC (permalink / raw)
  To: Thiago Farina; +Cc: git

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
  2009-09-21  6:17 ` Johannes Sixt
@ 2009-09-21  6:45   ` Matthieu Moy
  2009-09-21 20:45     ` Thiago Farina
  0 siblings, 1 reply; 8+ messages in thread
From: Matthieu Moy @ 2009-09-21  6:45 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Thiago Farina, git

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/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Trivial fix: Display a more friendly message with  git-shell.
  2009-09-21  6:45   ` Matthieu Moy
@ 2009-09-21 20:45     ` Thiago Farina
  2009-09-22  7:28       ` Matthieu Moy
  0 siblings, 1 reply; 8+ messages in thread
From: Thiago Farina @ 2009-09-21 20:45 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Johannes Sixt, git

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?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Trivial fix: Display a more friendly message with  git-shell.
  2009-09-21 20:45     ` Thiago Farina
@ 2009-09-22  7:28       ` Matthieu Moy
  2009-09-22  8:15         ` Heiko Voigt
  2009-09-22  8:17         ` Jakub Narebski
  0 siblings, 2 replies; 8+ messages in thread
From: Matthieu Moy @ 2009-09-22  7:28 UTC (permalink / raw)
  To: Thiago Farina; +Cc: Johannes Sixt, git

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/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Re: [PATCH] Trivial fix: Display a more friendly message with git-shell.
  2009-09-22  7:28       ` Matthieu Moy
@ 2009-09-22  8:15         ` Heiko Voigt
  2009-09-22  8:17         ` Jakub Narebski
  1 sibling, 0 replies; 8+ messages in thread
From: Heiko Voigt @ 2009-09-22  8:15 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Thiago Farina, Johannes Sixt, git

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]))

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Trivial fix: Display a more friendly message with  git-shell.
  2009-09-22  7:28       ` Matthieu Moy
  2009-09-22  8:15         ` Heiko Voigt
@ 2009-09-22  8:17         ` Jakub Narebski
  1 sibling, 0 replies; 8+ messages in thread
From: Jakub Narebski @ 2009-09-22  8:17 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: Thiago Farina, Johannes Sixt, git

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-09-22  8:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-20 17:11 [PATCH] Trivial fix: Display a more friendly message with git-shell Thiago Farina
2009-09-21  4:21 ` Tay Ray Chuan
2009-09-21  6:17 ` Johannes Sixt
2009-09-21  6:45   ` Matthieu Moy
2009-09-21 20:45     ` Thiago Farina
2009-09-22  7:28       ` Matthieu Moy
2009-09-22  8:15         ` Heiko Voigt
2009-09-22  8:17         ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).