diff mbox series

[v5,08/15] bugreport: include user interactive shell

Message ID 20200124033436.81097-9-emilyshaffer@google.com (mailing list archive)
State New, archived
Headers show
Series add git-bugreport tool | expand

Commit Message

Emily Shaffer Jan. 24, 2020, 3:34 a.m. UTC
From: Emily Shaffer <emilyshaffer@google.com>

It's possible a user may complain about the way that Git interacts with
their interactive shell, e.g. autocompletion or shell prompt. In that
case, it's useful for us to know which shell they're using
interactively.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
---
 bugreport.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Martin Ågren Jan. 30, 2020, 10:28 p.m. UTC | #1
On Fri, 24 Jan 2020 at 04:41, <emilyshaffer@google.com> wrote:
> +       char *shell = NULL;

(Unnecessary initialization.)

> +       shell = getenv("SHELL");
> +       strbuf_addf(sys_info, "$SHELL (typically, interactive shell): %s\n",
> +                   shell ? shell : "(NULL)");

Thanks for avoiding a classic pitfall. :-)

"<unused>" instead of "(NULL)"? "NULL" is mostly an implementation
detail.


Martin
Emily Shaffer Feb. 4, 2020, 11:16 p.m. UTC | #2
On Thu, Jan 30, 2020 at 11:28:40PM +0100, Martin Ågren wrote:
> On Fri, 24 Jan 2020 at 04:41, <emilyshaffer@google.com> wrote:
> > +       char *shell = NULL;
> 
> (Unnecessary initialization.)
> 
> > +       shell = getenv("SHELL");
> > +       strbuf_addf(sys_info, "$SHELL (typically, interactive shell): %s\n",
> > +                   shell ? shell : "(NULL)");
> 
> Thanks for avoiding a classic pitfall. :-)

Thank Junio. I fell right into it because it Just Works in gcc. ;)

> "<unused>" instead of "(NULL)"? "NULL" is mostly an implementation
> detail.

Sure, why not.
Junio C Hamano Feb. 5, 2020, 8:06 p.m. UTC | #3
Martin Ågren <martin.agren@gmail.com> writes:

> On Fri, 24 Jan 2020 at 04:41, <emilyshaffer@google.com> wrote:
>> +       char *shell = NULL;
>
> (Unnecessary initialization.)
>
>> +       shell = getenv("SHELL");
>> +       strbuf_addf(sys_info, "$SHELL (typically, interactive shell): %s\n",
>> +                   shell ? shell : "(NULL)");
>
> Thanks for avoiding a classic pitfall. :-)
>
> "<unused>" instead of "(NULL)"? "NULL" is mostly an implementation
> detail.

Isn't that <unset>?
Martin Ågren Feb. 5, 2020, 8:14 p.m. UTC | #4
On Wed, 5 Feb 2020 at 21:06, Junio C Hamano <gitster@pobox.com> wrote:
>
> Martin Ågren <martin.agren@gmail.com> writes:
>
> > On Fri, 24 Jan 2020 at 04:41, <emilyshaffer@google.com> wrote:
> >> +       char *shell = NULL;
> >
> > (Unnecessary initialization.)
> >
> >> +       shell = getenv("SHELL");
> >> +       strbuf_addf(sys_info, "$SHELL (typically, interactive shell): %s\n",
> >> +                   shell ? shell : "(NULL)");
> >
> > Thanks for avoiding a classic pitfall. :-)
> >
> > "<unused>" instead of "(NULL)"? "NULL" is mostly an implementation
> > detail.
>
> Isn't that <unset>?

Heh, yes, "SHELL: unused" sounds wrong. :-)

Martin
diff mbox series

Patch

diff --git a/bugreport.c b/bugreport.c
index 73f6d39517..07b84b9c94 100644
--- a/bugreport.c
+++ b/bugreport.c
@@ -22,6 +22,7 @@  static void get_system_info(struct strbuf *sys_info)
 {
 	struct strbuf version_info = STRBUF_INIT;
 	struct utsname uname_info;
+	char *shell = NULL;
 
 	/* get git version from native cmd */
 	strbuf_addstr(sys_info, "git version:\n");
@@ -44,6 +45,10 @@  static void get_system_info(struct strbuf *sys_info)
 	get_compiler_info(sys_info);
 	strbuf_complete_line(sys_info);
 
+	shell = getenv("SHELL");
+	strbuf_addf(sys_info, "$SHELL (typically, interactive shell): %s\n",
+		    shell ? shell : "(NULL)");
+
 	strbuf_addstr(sys_info, "git-remote-https --build-info:\n");
 	get_curl_version_info(sys_info);
 	strbuf_complete_line(sys_info);