All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] bugreport: collect shell settings
@ 2020-05-12 23:42 Emily Shaffer
  2020-05-12 23:42 ` [PATCH 1/2] help: add shell-path to --build-options Emily Shaffer
  2020-05-12 23:42 ` [PATCH 2/2] bugreport: include user interactive shell Emily Shaffer
  0 siblings, 2 replies; 7+ messages in thread
From: Emily Shaffer @ 2020-05-12 23:42 UTC (permalink / raw)
  To: git; +Cc: Emily Shaffer

Note: To avoid merge conflicts, this is based on
es/bugreport-with-hooks. It doesn't rely on any of the content in that
patch and the conflicts would be straightforward to resolve, but they
would be annoying. (If that's not the right way to go about something
like this, let me know - I've got a handful more bugreport topics to go
after this one.)

The first patch in the series captures the shell we use during build
(e.g. to run GIT-VERSION-GEN) and the second patch captures the user
shell at runtime.

 - Emily

Emily Shaffer (2):
  help: add shell-path to --build-options
  bugreport: include user interactive shell

 Documentation/git-bugreport.txt | 1 +
 bugreport.c                     | 6 ++++++
 help.c                          | 1 +
 3 files changed, 8 insertions(+)

-- 
2.26.2.645.ge9eca65c58-goog


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

* [PATCH 1/2] help: add shell-path to --build-options
  2020-05-12 23:42 [PATCH 0/2] bugreport: collect shell settings Emily Shaffer
@ 2020-05-12 23:42 ` Emily Shaffer
  2020-05-12 23:59   ` brian m. carlson
  2020-05-12 23:42 ` [PATCH 2/2] bugreport: include user interactive shell Emily Shaffer
  1 sibling, 1 reply; 7+ messages in thread
From: Emily Shaffer @ 2020-05-12 23:42 UTC (permalink / raw)
  To: git; +Cc: Emily Shaffer

It may be useful to know which shell Git was built to try to point to,
in the event that shell-based Git commands are failing. $SHELL_PATH is
set during the build and used to launch the manpage viewer, as well as
by git-compat-util.h, and it's used during tests. 'git version
--build-options' is encouraged for use in bug reports, so it makes sense
to include this information there.

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

diff --git a/help.c b/help.c
index 1de9c0d589..44cee69c11 100644
--- a/help.c
+++ b/help.c
@@ -641,6 +641,7 @@ void get_version_info(struct strbuf *buf, int show_build_options)
 			strbuf_addstr(buf, "no commit associated with this build\n");
 		strbuf_addf(buf, "sizeof-long: %d\n", (int)sizeof(long));
 		strbuf_addf(buf, "sizeof-size_t: %d\n", (int)sizeof(size_t));
+		strbuf_addf(buf, "shell-path: %s\n", SHELL_PATH);
 		/* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
 	}
 }
-- 
2.26.2.645.ge9eca65c58-goog


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

* [PATCH 2/2] bugreport: include user interactive shell
  2020-05-12 23:42 [PATCH 0/2] bugreport: collect shell settings Emily Shaffer
  2020-05-12 23:42 ` [PATCH 1/2] help: add shell-path to --build-options Emily Shaffer
@ 2020-05-12 23:42 ` Emily Shaffer
  1 sibling, 0 replies; 7+ messages in thread
From: Emily Shaffer @ 2020-05-12 23:42 UTC (permalink / raw)
  To: git; +Cc: Emily Shaffer

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>
---
 Documentation/git-bugreport.txt | 1 +
 bugreport.c                     | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/Documentation/git-bugreport.txt b/Documentation/git-bugreport.txt
index 7fe9aef34e..4afc48c452 100644
--- a/Documentation/git-bugreport.txt
+++ b/Documentation/git-bugreport.txt
@@ -29,6 +29,7 @@ The following information is captured automatically:
  - uname sysname, release, version, and machine strings
  - Compiler-specific info string
  - A list of enabled hooks
+ - $SHELL
 
 This tool is invoked via the typical Git setup process, which means that in some
 cases, it might not be able to launch - for example, if a relevant config file
diff --git a/bugreport.c b/bugreport.c
index aa8a489c35..28f4568b01 100644
--- a/bugreport.c
+++ b/bugreport.c
@@ -9,6 +9,7 @@
 static void get_system_info(struct strbuf *sys_info)
 {
 	struct utsname uname_info;
+	char *shell = NULL;
 
 	/* get git version from native cmd */
 	strbuf_addstr(sys_info, _("git version:\n"));
@@ -29,8 +30,13 @@ static void get_system_info(struct strbuf *sys_info)
 
 	strbuf_addstr(sys_info, _("compiler info: "));
 	get_compiler_info(sys_info);
+
 	strbuf_addstr(sys_info, _("libc info: "));
 	get_libc_info(sys_info);
+
+	shell = getenv("SHELL");
+	strbuf_addf(sys_info, "$SHELL (typically, interactive shell): %s\n",
+		    shell ? shell : "<unset>");
 }
 
 static void get_populated_hooks(struct strbuf *hook_info, int nongit)
-- 
2.26.2.645.ge9eca65c58-goog


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

* Re: [PATCH 1/2] help: add shell-path to --build-options
  2020-05-12 23:42 ` [PATCH 1/2] help: add shell-path to --build-options Emily Shaffer
@ 2020-05-12 23:59   ` brian m. carlson
  2020-05-13  5:02     ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: brian m. carlson @ 2020-05-12 23:59 UTC (permalink / raw)
  To: Emily Shaffer; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 2314 bytes --]

On 2020-05-12 at 23:42:12, Emily Shaffer wrote:
> It may be useful to know which shell Git was built to try to point to,
> in the event that shell-based Git commands are failing. $SHELL_PATH is
> set during the build and used to launch the manpage viewer, as well as
> by git-compat-util.h, and it's used during tests. 'git version
> --build-options' is encouraged for use in bug reports, so it makes sense
> to include this information there.
> 
> Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> ---
>  help.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/help.c b/help.c
> index 1de9c0d589..44cee69c11 100644
> --- a/help.c
> +++ b/help.c
> @@ -641,6 +641,7 @@ void get_version_info(struct strbuf *buf, int show_build_options)
>  			strbuf_addstr(buf, "no commit associated with this build\n");
>  		strbuf_addf(buf, "sizeof-long: %d\n", (int)sizeof(long));
>  		strbuf_addf(buf, "sizeof-size_t: %d\n", (int)sizeof(size_t));
> +		strbuf_addf(buf, "shell-path: %s\n", SHELL_PATH);
>  		/* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */
>  	}
>  }

This seems straightforward and logical (as does the rest of the series),
but I wondered if it might be a good idea to try to interrogate the
shell for more information.  The reason I mention it is that Debian
permits any shell that meets certain standards to be /bin/sh, and all
programs that invoke /bin/sh must depend on only those features.  The
default is dash, but people could use bash, which is more featureful, or
posh, which is intentionally designed to provide the bare minimum
/bin/sh experience[0], among others.  A value of "/bin/sh" doesn't
necessarily tell us very much on Debian (or on macOS, for that matter).

Now, that of course does mean that we have to have some way to
distinguish between shells, and that is the hard part, so I'm completely
fine with us leaving it out until we have a good way to do it (or until
we decide we need it, which may be never).  I just wanted to mention it
as a potential approach for the future.  I'm happy with this series as
it stands right now.

[0] Quite literally, in that it's supposed to be a tool for testing
compatibility with the policy requirements.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

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

* Re: [PATCH 1/2] help: add shell-path to --build-options
  2020-05-12 23:59   ` brian m. carlson
@ 2020-05-13  5:02     ` Junio C Hamano
  2020-05-13  5:10       ` Eric Sunshine
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2020-05-13  5:02 UTC (permalink / raw)
  To: brian m. carlson; +Cc: Emily Shaffer, git

"brian m. carlson" <sandals@crustytoothpaste.net> writes:

> This seems straightforward and logical (as does the rest of the series),
> but I wondered if it might be a good idea to try to interrogate the
> shell for more information.  The reason I mention it is that Debian
> permits any shell that meets certain standards to be /bin/sh, and all
> programs that invoke /bin/sh must depend on only those features.  The
> default is dash, but people could use bash, which is more featureful, or
> posh, which is intentionally designed to provide the bare minimum
> /bin/sh experience[0], among others.  A value of "/bin/sh" doesn't
> necessarily tell us very much on Debian (or on macOS, for that matter).

Good point.  Perhaps readlink(3) on it, then?

lrwxrwxrwx 1 root root 9 Mar 11  2018 /bin/sh -> /bin/bash

> Now, that of course does mean that we have to have some way to
> distinguish between shells, and that is the hard part, so I'm completely
> fine with us leaving it out until we have a good way to do it (or until
> we decide we need it, which may be never).  I just wanted to mention it
> as a potential approach for the future.  I'm happy with this series as
> it stands right now.
>
> [0] Quite literally, in that it's supposed to be a tool for testing
> compatibility with the policy requirements.

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

* Re: [PATCH 1/2] help: add shell-path to --build-options
  2020-05-13  5:02     ` Junio C Hamano
@ 2020-05-13  5:10       ` Eric Sunshine
  2020-05-13 18:45         ` Emily Shaffer
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Sunshine @ 2020-05-13  5:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: brian m. carlson, Emily Shaffer, Git List

On Wed, May 13, 2020 at 1:02 AM Junio C Hamano <gitster@pobox.com> wrote:
> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
> > [...] A value of "/bin/sh" doesn't
> > necessarily tell us very much on Debian (or on macOS, for that matter).
>
> Good point.  Perhaps readlink(3) on it, then?
>
> lrwxrwxrwx 1 root root 9 Mar 11  2018 /bin/sh -> /bin/bash

That wouldn't help on Mac OS:

    $ ls -l /bin/sh /bin/bash
    -r-xr-xr-x  1 root  wheel  618448 Mar 18 22:04 /bin/bash
    -r-xr-xr-x  1 root  wheel  618512 Mar 18 22:04 /bin/sh

Although /bin/sh is neither a hard link nor a symbolic link to
/bin/bash, nor is the file size the same, it is nevertheless Bash (in
some form or another).

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

* Re: [PATCH 1/2] help: add shell-path to --build-options
  2020-05-13  5:10       ` Eric Sunshine
@ 2020-05-13 18:45         ` Emily Shaffer
  0 siblings, 0 replies; 7+ messages in thread
From: Emily Shaffer @ 2020-05-13 18:45 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Junio C Hamano, brian m. carlson, Git List

On Wed, May 13, 2020 at 01:10:36AM -0400, Eric Sunshine wrote:
> 
> On Wed, May 13, 2020 at 1:02 AM Junio C Hamano <gitster@pobox.com> wrote:
> > "brian m. carlson" <sandals@crustytoothpaste.net> writes:
> > > [...] A value of "/bin/sh" doesn't
> > > necessarily tell us very much on Debian (or on macOS, for that matter).
> >
> > Good point.  Perhaps readlink(3) on it, then?
> >
> > lrwxrwxrwx 1 root root 9 Mar 11  2018 /bin/sh -> /bin/bash
> 
> That wouldn't help on Mac OS:
> 
>     $ ls -l /bin/sh /bin/bash
>     -r-xr-xr-x  1 root  wheel  618448 Mar 18 22:04 /bin/bash
>     -r-xr-xr-x  1 root  wheel  618512 Mar 18 22:04 /bin/sh
> 
> Although /bin/sh is neither a hard link nor a symbolic link to
> /bin/bash, nor is the file size the same, it is nevertheless Bash (in
> some form or another).

Hum. It seems some useful things exist like $BASH_VERSION and
$ZSH_VERSION, but I'm not terribly excited about the idea of making a
list and checking each one in bugreport (as it's sure to be
nonexhaustive). I found a few more heuristics in a SO post[1] but this
approach generally looks like a pain, and somewhat unreliable.

Most other alternatives I found with a cursory Google involve checking
the name of the shell, which I think will have the same issues as
checking $SHELL:

 - `ps -p $$` for info about the current process (didn't reveal bash when I `cp
   /bin/bash ~/bin/nish && ~/bin/nish`)
 - `echo $0` since it's coming from the command line, of course will be
   the same as $SHELL

I suppose if we wanted to do the heuristics it'd be a better experience
for us, the bugreport receivers, to have the bugreport library collect
the heuristics and try to make a guess, rather than just dump all the
heuristics and let the humans try to remember which shell has $PS4 and
which shell has $version and so on. But to me that sounds prone to rot
at best.

 - Emily

[1]: https://stackoverflow.com/a/3327022

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

end of thread, other threads:[~2020-05-13 18:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 23:42 [PATCH 0/2] bugreport: collect shell settings Emily Shaffer
2020-05-12 23:42 ` [PATCH 1/2] help: add shell-path to --build-options Emily Shaffer
2020-05-12 23:59   ` brian m. carlson
2020-05-13  5:02     ` Junio C Hamano
2020-05-13  5:10       ` Eric Sunshine
2020-05-13 18:45         ` Emily Shaffer
2020-05-12 23:42 ` [PATCH 2/2] bugreport: include user interactive shell Emily Shaffer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.