This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-3-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 605126ce00ef981c1c0a7bb1977245f5b57ad75f Author: Matt Rixman <[email protected]> AuthorDate: Thu Jul 28 11:39:35 2022 -0600 fix - resolve bash by absolute path (#25331) Co-authored-by: Matt Rixman <[email protected]> (cherry picked from commit c3adf3e65d32d8145e2341989a5336c3e5269e62) --- airflow/operators/bash.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/airflow/operators/bash.py b/airflow/operators/bash.py index a4fac2b7f7..47c7a6398f 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 @@ -176,6 +177,7 @@ class BashOperator(BaseOperator): 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}") @@ -183,7 +185,7 @@ class BashOperator(BaseOperator): 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,
