git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] Make running git under other debugger-like programs easy

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 10, 2018, 08:26 UTC
Message-ID
<nycvar.QRO.7.76.6.1804101023100.55@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz>
In-Reply-To
<CABPp-BF4x-ppjptq1TBj+VicvGeWGbfj4e3f5ne_13AEKmvSQQ@mail.gmail.com>
Hi Elijah,
On Mon, 9 Apr 2018, Elijah Newren wrote:
Show 19 quoted lines
> On Mon, Apr 9, 2018 at 2:19 PM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> >
> > On Mon, 9 Apr 2018, Elijah Newren wrote:
> >
> >>  debug () {
> >> -      GIT_TEST_GDB=1 "$@" <&6 >&5 2>&7
> >> +     case "$1" in
> >> +     -d)
> >> +             DBG_FLAGS="$2" &&
> >
> > Maybe we can find a way that does not require setting a variable other
> > than GIT_DEBUGGER? After all, DBG_FLAGS will be visible to the script
> > calling `debug`...
> 
> I guess we could instead do a
>    export GIT_DEBUGGER="$2"
> here.  Short of explicitly using 'export', I think we'd need another
> environment variable.

I suppose so. The GIT_DEBUGGER variable has to be exported *anyway*, otherwise the bin-wrappers/* won't see it.

Show 5 quoted lines
> I would have stuck with your original suggestion, except that by running:
>     GIT_DEBUGGER="$1" debug_aux "$@"
> GIT_DEBUGGER would be set within the debug_aux function and would NOT
> be set once bin-wrappers/git was called, making git not run under the
> debugger as desired.
Oh, so in debug_aux, you'd have to do some funny
	GIT_DEBUGGER="$GIT_DEBUGGER" "$@"
to export that variable to the process... Ugly.
Show 12 quoted lines
> >> +*)
> >> +     GIT_DEBUGGER_ARGS="$GIT_DEBUGGER"
> >> +     unset GIT_DEBUGGER
> >> +     exec ${GIT_DEBUGGER_ARGS} "${GIT_EXEC_PATH}/@@PROG@@" "$@"
> >
> > It may not be a big deal, bug GIT_DEBUGGER_ARGS (if it was exported e.g.
> > by the user calling the script) is now visible by the called process... (I
> > thought I had tried my best to avoid such a leaking variable in my
> > patch...)
> 
> You had a separate, per-process variable:
> GIT_DEBUGGER_$$="$GIT_DEBUGGER"

Right. And I guess it does not work because the _$$ is not expanded, you'd have to eval it, and then you'd have to quote the right side appropriately, and it's all not worth it.

Show 11 quoted lines
> The problem with that line is that the $$ apparently makes bash treat
> it as a command to run rather than as a variable and a value with the
> desire to set one to the other.  Prepending the line with 'declare' or
> 'local' or perhaps 'readonly' would fix that, but those aren't posix
> and my reading suggested that while some other shells did support some
> of those builtins, the support was somewhat spotty.  Since
> wrap-for-bin.sh runs under /bin/sh, not /bin/bash, I didn't have a way
> of making the per-process piece work and just fell back to a separate
> variable.  Maybe we want to change that script to /bin/bash?
> 
> Do you see any alternatives I'm missing?
No, not really.
Well, let's stick with your patch (with s/DBG_FLAGS/GIT_DEBUGGER/).

Thanks, Dscho

Previous: Elijah NewrenNext: Elijah Newren
Message 9 of 12 in “Make running git under other debugger-like programs easy”
  1. Make running git under other debugger-like programs easyElijah Newren, Apr 5, 2018
  2. Johannes SchindelinApr 5, 2018
  3. Elijah NewrenApr 5, 2018
  4. Johannes SchindelinApr 6, 2018
  5. Elijah NewrenApr 6, 2018
  6. Make running git under other debugger-like programs easyElijah Newren, Apr 9, 2018
  7. Johannes SchindelinApr 9, 2018
  8. Elijah NewrenApr 10, 2018
  9. Johannes SchindelinApr 10, 2018
  10. Make running git under other debugger-like programs easyElijah Newren, Apr 24, 2018
  11. Johannes SchindelinApr 25, 2018
  12. Junio C HamanoApr 26, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.