* git hard-codes use of /bin/sh for aliases
@ 2026-05-11 21:13 Thorsten Glaser
2026-05-11 22:38 ` brian m. carlson
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Glaser @ 2026-05-11 21:13 UTC (permalink / raw)
To: git
Hi,
git aliases don’t use the user’s shell but a hardcoded /bin/sh,
and this cannot be made configurable.
This, unfortunately, breaks quite some aliases and they cannot
be made portable by adding something like core.sh = /bin/mksh
to the .gitconfig.
I’d love if this could be made configurable.
bye,
//Thorsten
--
Thorsten Glaser
Linux / Unix Developer
Tel.: +49 160 91168501
E-Mail: tglaser@b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / https://www.b1-systems.de/
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt, HRB 3537
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git hard-codes use of /bin/sh for aliases
2026-05-11 21:13 git hard-codes use of /bin/sh for aliases Thorsten Glaser
@ 2026-05-11 22:38 ` brian m. carlson
2026-05-11 22:46 ` Thorsten Glaser
0 siblings, 1 reply; 3+ messages in thread
From: brian m. carlson @ 2026-05-11 22:38 UTC (permalink / raw)
To: Thorsten Glaser; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 2829 bytes --]
On 2026-05-11 at 21:13:18, Thorsten Glaser wrote:
> Hi,
>
> git aliases don’t use the user’s shell but a hardcoded /bin/sh,
> and this cannot be made configurable.
>
> This, unfortunately, breaks quite some aliases and they cannot
> be made portable by adding something like core.sh = /bin/mksh
> to the .gitconfig.
>
> I’d love if this could be made configurable.
Yes, I believe they use `/bin/sh`, except on Windows, where they may
look up things in the PATH. It is very much intentional that they use
sh because it means that aliases work in a consistent way across
platforms and that they work at all.
On Linux, I have mksh, but my work machine on macOS does not, so
specifying `core.sh = /bin/mksh` would not work on all my systems. If
you have system-level aliases as well as user-level aliases, then you
need to pick a particular shell and letting the user choose will likely
break the system-level aliases. This is not a hypothetical: my last
company shipped system-level aliases on development VMs while users were
free to customize their user-level aliases (and shell).
This will absolutely be a problem on Windows, where you have CMD,
multiple versions of PowerShell, and bash, all with different syntax.
Some versions of PowerShell also corrupt non-Unicode data sent through
pipelines as well, which means they're effectively useless for
general-purpose scripting.
It can also lead to odd behaviour on some shells because, for instance,
zsh runs a config file with `-c`, `.zshenv`, that can make the shell
very much less POSIX compliant, so behaviour can differ substantially
from sh.
I'll also note that Git doesn't handle aliases specially. Git has a
with-shell and a without-shell mode for running commands, and we use the
former for aliases. We definitely do not want the with-shell mode to
generically allow arbitrary shells because we cannot handle non-POSIX
shells and will not quote correctly for them (almost certainly leading
to security vulnerabilities). We also format the shell command as "%s
\"$@\"", which also basically requires a POSIX shell to work, and we
don't want to work around people's use of non-POSIX shells; that way
madness lies.
However, because mksh is POSIXy, you could build Git on your system with
`SHELL_PATH=/bin/mksh`, which would use `/bin/mksh` everywhere that the
shell is invoked. That feature exists primarily for systems where `sh`
is not POSIXy or doesn't support `local` (which I know mksh does), but
there's no reason you can't use it yourself.
There has been some discussion about this issue in the past (in the
context of PowerShell) at
https://lore.kernel.org/git/CAAXzdLXt4+-34+OhS=Jn=-VeORN3Y2jMzzg9+bhyn88aN4hm0A@mail.gmail.com/ .
--
brian m. carlson (they/them)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 325 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git hard-codes use of /bin/sh for aliases
2026-05-11 22:38 ` brian m. carlson
@ 2026-05-11 22:46 ` Thorsten Glaser
0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Glaser @ 2026-05-11 22:46 UTC (permalink / raw)
To: brian m. carlson; +Cc: git
On Mon, 11 May 2026, brian m. carlson wrote:
>On Linux, I have mksh, but my work machine on macOS does not, so
>specifying `core.sh = /bin/mksh` would not work on all my systems. If
But it could be made possible by pointing it to ~/.etc/bin/mksh
on the Macintosh…
>I'll also note that Git doesn't handle aliases specially. Git has a
>with-shell and a without-shell mode for running commands, and we use the
>former for aliases.
Ah, okay.
I was merely wondering that it was not configurable for aliases.
When looking at the aliases in detail, I found that I already invoked
mksh -c '…' in those that used mksh-specific code, and that the one
that failed merely uses a recent POSIX sh construct that /bin/sh on
a customer system does not yet implement and I could reword it.
bye,
//Thorsten
--
Thorsten Glaser
Linux / Unix Developer
Tel.: +49 160 91168501
E-Mail: tglaser@b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / https://www.b1-systems.de/
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt, HRB 3537
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 22:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 21:13 git hard-codes use of /bin/sh for aliases Thorsten Glaser
2026-05-11 22:38 ` brian m. carlson
2026-05-11 22:46 ` Thorsten Glaser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox