What determines the Shell used by Mercurial?

Dr. Rainer Woitok Rainer.Woitok at rrze.uni-erlangen.de
Tue Aug 24 14:05:24 UTC 2010


Mads and Others,

On Tuesday, 2010-08-24 12:56:26 +0200, Mads Kiilerich wrote:

> ...
> Try to verify manually that "/bin/sh -c ~/test-hook" works.

You almost got  me on this  one :-) Of  course it works!  At least  when
called from  any decent shell which  knows about tilde expansion.  But a
pure Bourne Shell doesn't know about that:

bad$ /bin/sh
bad$ cd $HOME
bad$ ls -l test-hook
-rwx------   1 user     group         20 Aug 24 15:17 test-hook
bad$ /bin/sh -c ~/test-hook
/bin/sh: ~/test-hook: not found
bad$

Maybe  the Solaris "/bin/sh"  really is  a pure Bourne  Shell while some
"/bin/sh" programs under other  operating systems are already "enriched"
in one way or  another.  But you can  hardly claim the Solaris "/bin/sh"
to be broken.

So  a way out would probably  be to have  Mercurial  preprocess any hook
statements in the same way a tilde-aware shell  would do before Mecurial
passes them on to "/bin/sh".

An even  better fix would  be to provide a means  in the ".hgrc" file to
specify the  command to be used to  launch external hooks (with "/bin/sh
-c"  being the default).  This would  also solve the  problem  of a pure
Bourne  Shell  choking  on  the  widely   published  hook  specification
"prechangegroup.PatchesNoPull = !  hg qtop > /dev/null  2>&1" or  on the
use of "$(...)" rather than "`...`".

Sincerely,
  Rainer



More information about the Mercurial mailing list