public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Ian Wienand <iwienand@redhat.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] alias: pass --help through to shell alias
Date: Sat, 25 May 2024 11:36:08 +1000	[thread overview]
Message-ID: <ZlFAiMAOaBK1Qrrw@fedora19.localdomain> (raw)
In-Reply-To: <xmqq8qzyk9u8.fsf@gitster.g>

On Fri, May 24, 2024 at 05:34:55PM -0700, Junio C Hamano wrote:
> Ian Wienand <iwienand@redhat.com> writes:
> This is a safe behaviour because the underlying command may not be
> prepared to see "--help" and ignore it silently in the best case,
> e.g.
> 
>     sh -c 'false "$@" || :' - --help
> 
> that would confuse users by being totally silent, or 
> 
>     sh -c 'awk "$@" || :' - --help
> 
> that gives "awk: not an option: --help" (which is less useful than
> the report of alias),

The proposed patch does still print the alias expansion before trying
to pass the "--help" onto the command.  That was intention to be the
same as "-h" behaviour.  But I take your point the error message
doesn't help.

> or even worse yet, if the underlying command
> does not understand "--help" and considers it something different,
> who knows what havoc it would wreak.

I guess this means that someone was relying on git to filter out
--help such that it would never get to their command.  To me this
could probably be considered "undefined behaviour" that is probably
low risk to change, but I understand the aversion to it.

> For the above reason ...
> 
> > I would propose that "--help" to a shell alias is passed through to
> > the underlying command.  This way you can write aliases that act more
> > like the other git commands.
> 
> ... this is a dangerous thing to do unconditionally.
> 
> I wonder if we can come up with a notation to annotate aliases that
> do support the "--help" option that wouldn't have been used by
> mistake for existing aliases?

We could do something like make "!!" as an alias prefix also passes
this through.  It seems too niche to bother with though, TBH.

I could propose documenting the behaviour as-is, although that
probably moves it from undefined behaviour to "this will never
change".  I'll take advice on what you think :)

-i


      reply	other threads:[~2024-05-25  1:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-24  7:04 [PATCH] alias: pass --help through to shell alias Ian Wienand
2024-05-25  0:34 ` Junio C Hamano
2024-05-25  1:36   ` Ian Wienand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZlFAiMAOaBK1Qrrw@fedora19.localdomain \
    --to=iwienand@redhat.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox