I have bash script and it requires bash.
Another person try to run it with
sh script_name.sh
And it fails because sh is symbolic link to dash in his distribution.
$ ls -la /bin/sh
lrwxrwxrwx 1 root root 4 Aug 25 16:06 /bin/sh -> dash
I have an idea to use wrapper script:
#!/bin/sh
bash script_name.sh
The goal is to run .sh script by sh with bash in system having symbolic link to dash.
In your script before you anything else, you can do something like:
or the more general way is using
$BASH_VERSION
:Well, usually you use the shebang to tell the shell to use the correct interpreter:
You have to set the script to be executable:
And let the user start it with:
It seems simple than to use a wrapper script.
You can use jbr test to run your script with bash even if the user use sh/dash or any sh like interpreter:
This way it correctly works with either :