we have a lot of sh scripts and we want to upgrade them to bash scripts
my question:
dose bash support any previous sh script ?
if not what need to know before we convert sh to bash ? I mean what we need to change/replace in the sh script to be bash script
I have unfortunately seen only a limited number of attempts to convert shell scripts from legacy UNIX platforms to bash. Usually there were uneventful.
One interesting example I remember was a script which used non-POSIX-conforming expansion behavior for <<here
documents to implement a goto
, presumably to simplify porting .bat
scripts from MS-DOS or Windows. (The “labels” started with a colon :
.) This did not work in bash because it follows POSIX semantics, so here documents could not be used to conditionally remove sections of the shell script.
In practice, the larger issue is often with the programs called from the shell scripts, which can show behavioral differences as well.
So the answer is a rather unsatisfying “it depends”, I'm afraid.