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

Re: [PATCH 1/2] help: add shell-path to --build-options

From
Emily Shaffer <emilyshaffer@google.com>
Date
May 13, 2020, 18:45 UTC
Message-ID
<20200513184507.GA196295@google.com>
In-Reply-To
<CAPig+cRGrExRsucs8pmmiP+Zc2CmR3AU=8ACuiyH9tkz9JSCgQ@mail.gmail.com>
On Wed, May 13, 2020 at 01:10:36AM -0400, Eric Sunshine wrote:
Show 19 quoted lines
> 
> 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
Previous: Eric SunshineNext: Emily Shaffer
Message 6 of 7 in “bugreport: collect shell settings”
  1. 0/2 bugreport: collect shell settingsEmily Shaffer, May 12, 2020
  2. 1/2 help: add shell-path to --build-optionsEmily Shaffer, May 12, 2020
  3. brian m. carlsonMay 12, 2020
  4. Junio C HamanoMay 13, 2020
  5. Eric SunshineMay 13, 2020
  6. Emily ShafferMay 13, 2020
  7. 2/2 bugreport: include user interactive shellEmily Shaffer, May 12, 2020

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.