Skip to content

Commit

Permalink
fix - resolve bash by absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
MatrixManAtYrService committed Jul 27, 2022
1 parent 8bc1471 commit d917d3d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion airflow/operators/bash.py
Expand Up @@ -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
Expand Down Expand Up @@ -174,14 +175,15 @@ 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}")
if not os.path.isdir(self.cwd):
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,
Expand Down

0 comments on commit d917d3d

Please sign in to comment.