I have switched to zsh, how can I run a script which is written for bash?
I don't want to modify the script to put #!/bin/bash in the beginning for the script since it is version controlled.
Is there another way?
The line of the script having problem is:
for f in `/bin/ls v/*/s.sh v/*/*/v.sh d/*/*/v.sh 2> /dev/null` 2 2 Answers
You can run the script with bash manually:
bash myscript.shA better and more permanent solution is to add a shebang line:
#!/usr/bin/env bashOnce that line is added, you can run it directly, even in ZShell:
% ./myscript.shAs far as version control goes, you should commit this line, for the good of all the developers involved.
2In addition to the solution commented by @neersighted, you should also make sure your bash script has the executive permission to run in the zsh. Thus, you should first set the first line of your bash script with shabang:
#!/usr/bin/env bashThen run:
% chmod +x myscript.shto provide such permission. Then you can run it in zsh as:
% ./myscript.sh 3