bitwelder
bitwelder

Reputation: 1093

Check if a script really requires specific shell to run?

I should deploy some scripts that have been written for bash to various Linux/Unix machines where I may not have bash natively available. I do not know if the original writer really required bash to run the scripts or it's just because it's default shell in modern Linuxes.

Do you know of any script, application or online service that takes as input a shell script, does some syntax checks using the grammar for several common shells and returns as output some kind of validation estimate like "This script should be run under one of the following shells: ash, bash, ksh, zsh".

Upvotes: 1

Views: 68

Answers (1)

John Szakmeister
John Szakmeister

Reputation: 46992

I don't know of any tool that does what you're asking for, but there is one called checkbashisms that can at least check for non-portable syntax. IIRC, it's packaged in Ubuntu as part of the devscripts package.

Ubuntu also made the switch to having dash be the default shell and wrote a helpful page about coping with the change of making Dash be /bin/sh. I've found it to be a good reference.

Upvotes: 3

Related Questions