Upload: bash-3.0-4 [test]

Eric Blake ericblake@comcast.net
Tue Jul 5 19:52:00 GMT 2005

> > Or, I could first do "cygcheck /bin/sh.exe", and see if "Error: could
> > not find <libname>.dll" appears in the output [...]
> Or even just test -f...

"test -f /bin/sh.exe" checks whether /bin/sh exists.  From there,
"cygcheck /bin/sh.exe" and parsing the output for "Error: could not find"
checks whether attempting to run sh would cause a popup box.  (Too
bad cygcheck exit status doesn't currently work).  So, how about this,
which only runs /bin/sh --version if cygcheck found no missing


# Update /bin/sh to be this version of bash if it is missing, ash,
# older bash, or un-runnable.  Leave it alone if it is anything else.

running=yes update=yes
test -x /bin/sh.exe || running=no  # missing executable
case `cygcheck /bin/sh.exe` in
    *Error:\ could\ not\ find*) running=no;;  # missing library
test $running = yes && case `/bin/sh.exe --version 2>&1` in
    Illegal\ option\ --*) ;; # ash
    GNU\ bash*) ;; # possibly-older version of bash
    *) update=no ;; # leave anything else alone
test $update = yes && ln -f /bin/bash.exe /bin/sh.exe

This works even on the upgrade path that Igor originally complained
about, without requiring a separate preremove.  Users wanting to
completely uninstall cygwin already have enough other files which
setup.exe won't remove, that leaving a dangling /bin/sh won't be
any worse than the status quo.

Eric Blake

More information about the Cygwin-apps mailing list