wellington-junio / gitblit

Automatically exported from code.google.com/p/gitblit
Apache License 2.0
0 stars 0 forks source link

replace /bin/bash with /bin/sh for more compatibility #554

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
your shell scripts to start and stop gitblit work with a simple sh shell, so 
there is no need to force bash. /bin/sh is available on every UNIX and 
UNIX-like system, while /bin/bash is not (e.g. FreeBSD).

I would suggest replacing
#!/bin/bash
with
#!/bin/sh
in the scripts which are part of gitblit go.

in service-centos.sh (works on FreeBSD, too) the only change you need to do is 
replace 
source ${GITBLIT_PATH}/java-proxy-config.sh
with
. ${GITBLIT_PATH}/java-proxy-config.sh

Original issue reported on code.google.com by oliverk...@gmail.com on 29 Jan 2015 at 8:53

GoogleCodeExporter commented 9 years ago
I'm not opposed to this idea, but I don't currently plan to change it.  I'm not 
expert enough on all the variations in shell syntax.  I'm sure "." is available 
in most if not all shells, but what about conditionals and switches?  Is that 
the same between bash, csh, zsh, fish, etc, etc?  I'm not totally sure.

Original comment by James.Mo...@gmail.com on 26 Feb 2015 at 2:17

GoogleCodeExporter commented 9 years ago
well, /bin/sh on all systems I know is either ash, ksh, bash or dash (all sh 
compatible). If it would be a shell with non-sh-like syntax even the 
boot-process would fail as it does depends massively on sh scripts. E.g. look 
at /etc/init.d on Ubuntu. Most of these scripts using /bin/sh (= dash on 
ubuntu) as interpreter.

for a overview on what's defined in the sh language, look here:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html

TL;DR: Most syntatic features from bash are available in sh, with a few 
differences like substrings in variables, etc. Nothing you would probably need 
in an init script.

Another option would be to use #!/usr/bin/env bash - which, while not POSIX 
compliant, works on every half-way modern unix system and calls the bash from 
their correct path (e.g. on FreeBSD /usr/local/bin/bash, if installed from 
ports).

Original comment by oliverk...@gmail.com on 2 Mar 2015 at 2:49