diff --git a/providers/standard/src/airflow/providers/standard/operators/bash.py b/providers/standard/src/airflow/providers/standard/operators/bash.py index 8f5205c11bd8e..101236949df88 100644 --- a/providers/standard/src/airflow/providers/standard/operators/bash.py +++ b/providers/standard/src/airflow/providers/standard/operators/bash.py @@ -178,10 +178,6 @@ def __init__( self.cwd = cwd self.append_env = append_env self.output_processor = output_processor - self._is_inline_cmd = None - if isinstance(bash_command, str): - self._is_inline_cmd = self._is_inline_command(bash_command=bash_command) - @cached_property def subprocess_hook(self): """Returns hook for running the bash command.""" @@ -215,7 +211,11 @@ def execute(self, context: Context): raise AirflowException(f"The cwd {self.cwd} must be a directory") env = self.get_env(context) - if self._is_inline_cmd: + is_inline_cmd = isinstance(self.bash_command, str) and self._is_inline_command( + bash_command=self.bash_command + ) + + if is_inline_cmd: result = self._run_inline_command(bash_path=bash_path, env=env) else: result = self._run_rendered_script_file(bash_path=bash_path, env=env) diff --git a/scripts/ci/prek/validate_operators_init_exemptions.txt b/scripts/ci/prek/validate_operators_init_exemptions.txt index 0890990686d76..23b8f1851bfbf 100644 --- a/scripts/ci/prek/validate_operators_init_exemptions.txt +++ b/scripts/ci/prek/validate_operators_init_exemptions.txt @@ -55,6 +55,5 @@ providers/microsoft/azure/src/airflow/providers/microsoft/azure/transfers/oracle providers/microsoft/psrp/src/airflow/providers/microsoft/psrp/operators/psrp.py::PsrpOperator providers/oracle/src/airflow/providers/oracle/transfers/oracle_to_oracle.py::OracleToOracleOperator providers/papermill/src/airflow/providers/papermill/operators/papermill.py::PapermillOperator -providers/standard/src/airflow/providers/standard/operators/bash.py::BashOperator providers/standard/src/airflow/providers/standard/operators/trigger_dagrun.py::TriggerDagRunOperator providers/standard/src/airflow/providers/standard/sensors/date_time.py::DateTimeSensor