diff --git a/airflow/operators/bash.py b/airflow/operators/bash.py index b470f4d85f442..15e0a6cafae71 100644 --- a/airflow/operators/bash.py +++ b/airflow/operators/bash.py @@ -16,6 +16,7 @@ # specific language governing permissions and limitations # under the License. import os +import shutil from typing import Dict, Optional, Sequence from airflow.compat.functools import cached_property @@ -174,6 +175,7 @@ def get_env(self, context): return env def execute(self, context: Context): + bash_path = shutil.which("bash") or "bash" if self.cwd is not None: if not os.path.exists(self.cwd): raise AirflowException(f"Can not find the cwd: {self.cwd}") @@ -181,7 +183,7 @@ def execute(self, context: Context): raise AirflowException(f"The cwd {self.cwd} must be a directory") env = self.get_env(context) result = self.subprocess_hook.run_command( - command=['bash', '-c', self.bash_command], + command=[bash_path, '-c', self.bash_command], env=env, output_encoding=self.output_encoding, cwd=self.cwd,