You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2022/07/28 17:39:51 UTC

[airflow] branch main updated: fix - resolve bash by absolute path (#25331)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new c3adf3e65d fix - resolve bash by absolute path (#25331)
c3adf3e65d is described below

commit c3adf3e65d32d8145e2341989a5336c3e5269e62
Author: Matt Rixman <58...@users.noreply.github.com>
AuthorDate: Thu Jul 28 11:39:35 2022 -0600

    fix - resolve bash by absolute path (#25331)
    
    Co-authored-by: Matt Rixman <Ma...@users.noreply.github.com>
---
 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 b470f4d85f..15e0a6cafa 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 @@ 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}")
@@ -181,7 +183,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,