var: add support for listing the shell
commit1e6572122702cbf0e3b6d3226f73e6b8b45e6e37
authorbrian m. carlson <bk2204@github.com>
Tue, 27 Jun 2023 16:18:57 +0000 (27 16:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Jun 2023 18:31:05 +0000 (27 11:31 -0700)
tree6a6bab9c2cd02d79d8d04de41c7dcfa11e40784d
parentd6546af75c3cda2815f2e4d5322dd7a41cc0963b
var: add support for listing the shell

On most Unix systems, finding a suitable shell is easy: one simply uses
"sh" with an appropriate PATH value.  However, in many Windows
environments, the shell is shipped alongside Git, and it may or may not
be in PATH, even if Git is.

In such an environment, it can be very helpful to query Git for the
shell it's using, since other tools may want to use the same shell as
well.  To help them out, let's add a variable, GIT_SHELL_PATH, that
points to the location of the shell.

On Unix, we know our shell must be executable to be functional, so
assume that the distributor has correctly configured their environment,
and use that as a basic test.  On Git for Windows, we know that our
shell will be one of a few fixed values, all of which end in "sh" (such
as "bash").  This seems like it might be a nice test on Unix as well,
since it is customary for all shells to end in "sh", but there probably
exist such systems that don't have such a configuration, so be careful
here not to break them.

Signed-off-by: brian m. carlson <bk2204@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-var.txt
builtin/var.c
t/t0007-git-var.sh