Skip to content

Commit

Permalink
If batch script is already executable, don't chmod it
Browse files Browse the repository at this point in the history
Linux won't let you chmod files you don't own, so the old impl
can cause permissions problems when sharing cases.
  • Loading branch information
jgfouca committed Oct 31, 2024
1 parent 450cb5b commit 614fa55
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions CIME/XML/env_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,14 @@ def make_batch_script(self, input_template, job, case, outfile=None):
fd.write(output_text)

# make sure batch script is exectuble
os.chmod(
output_name,
os.stat(output_name).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH,
)
if not os.access(output_name, os.X_OK):
os.chmod(
output_name,
os.stat(output_name).st_mode
| stat.S_IXUSR
| stat.S_IXGRP
| stat.S_IXOTH,
)

def set_job_defaults(self, batch_jobs, case):
if self._batchtype is None:
Expand Down

0 comments on commit 614fa55

Please sign in to comment.