Is it potentially dangerous to run a bash script with sh?
9
votes
4
answers
2448
views
So obviously when you run a Bash script with
sh
(as in sh ./path/to/bash-script.sh
), you may experience errors in cases where sh is a symlink to a non-Bash shell that doesn't support a feature used in the script.
What I'm curious about is, if there could be a case where a script designed for Bash, executed by dash or some basic POSIX shell would cause code to be executed that otherwise definitely would not have been executed.
Everything I've tested (e.g. command grouping (( ... ))
) simply causes the script to exit early when executed with a primitive POSIX shell, not causing any potential damage.
Asked by Forivin
(1193 rep)
Nov 20, 2024, 02:40 PM
Last activity: Nov 23, 2024, 07:02 PM
Last activity: Nov 23, 2024, 07:02 PM