Skip to main content
remove excess words
Source Link
Toby Speight
  • 9.5k
  • 3
  • 32
  • 54

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 script to exit early when executed with a primitive POSIX shell, not causing any potential damage.

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 script to exit early when executed with a primitive POSIX shell, not causing any potential damage.

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.

Became Hot Network Question
Source Link
Forivin
  • 1.2k
  • 9
  • 25
  • 51

Is it potentially dangerous to run a bash script with sh?

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 script to exit early when executed with a primitive POSIX shell, not causing any potential damage.