Hi Johannes, On Thu, Apr 5, 2018 at 12:57 PM, Johannes Schindelin <Johannes.Schindelin@xxxxxx> wrote: > I wonder whether a better approach would be to add an optional argument to > that `debug` function (which is intended to have `git` as first argument, > anyway, or at least a command/function that does not start with a dash): > > debug_aux () { > shift > "$@" <&6 >&5 2>&7 > } > > debug () { > case "$1" in > -d) > shift && > GIT_TEST_GDB="$1" debug_aux "$@" > ;; > --debugger=*) > GIT_TEST_GDB="${1#*=}" debug_aux "$@" > ;; > *) > GIT_TEST_GDB=1 "$@" <&6 >&5 2>&7 > ;; > esac > } > > ... and then in wrap-for-bin.sh, we would replace the last lines > > if test -n "$GIT_TEST_GDB" > then > unset GIT_TEST_GDB > exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@" > else > exec "${GIT_EXEC_PATH}/@@PROG@@" "$@" > fi > > by > > case "$GIT_TEST_GDB" in > '') > exec "${GIT_EXEC_PATH}/@@PROG@@" "$@" > ;; > 1) > unset GIT_TEST_GDB > exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@" > ;; > *) > GIT_TEST_GDB_$$="$GIT_TEST_GDB" > unset GIT_TEST_GDB > exec $GIT_TEST_GDB_$$ "${GIT_EXEC_PATH}/@@PROG@@" "$@" > ;; > esac > > or some such. That all looks great to me. But at this point, it seems like it's a full rewrite and your patch to submit (which I'd be happy to endorse in lieu of my own)...or do you want me to submit with you as author and me as committer? Also, a side question: if we go this route, do we want to rename GIT_TEST_GDB to reflect its expanded usage? > Then your magic "GIT_WRAPPER" invocation would become a bit more explicit: > > debug --debugger=nemiver git $ARGS > debug -d "valgrind --tool=memcheck --track-origins=yes" git $ARGS No, for most (60-80%?) of my invocations, I wouldn't be able to use the debug function; only a minority of my uses are from within the testsuite. The rest are from the command line (I have git/bin-wrappers/ in my $PATH), so the above suggestions would mean that my invocation would become: GIT_TEST_GDB="nemiver" git $ARGS GIT_TEST_GDB="valgrind --tool-memcheck --track-origins=yes" git $ARGS > (In any case, "GIT_WRAPPER" is probably a name in want of being renamed.) Well, with your suggestion, it'd just be whatever that environment variable is named. I'm perfectly happy with something other than GIT_WRAPPER (or GIT_TEST_GDB). I'm not so good at coming up with such myself, but maybe something like GIT_DEBUGGER or GIT_DEBUG_WITH? Thanks, Elijah