Skip to content

Commit afcf6f7

Browse files
committed
cherry-picked bash changes from 4.2.0
1 parent 9eacf7a commit afcf6f7

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

autosubmit/job/template/bash.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@
2626
###################
2727
# Autosubmit header
2828
###################
29+
set -xvu
30+
declare locale_to_set
2931
locale_to_set=$(locale -a | grep ^C.)
32+
export job_name_ptrn='%CURRENT_LOGDIR%/%JOBNAME%'
33+
34+
r=0
35+
bash -e <<'__AS_CMD__'
36+
set -xve
3037
if [ -z "$locale_to_set" ] ; then
3138
# locale installed...
3239
export LC_ALL=$locale_to_set
@@ -39,27 +46,35 @@
3946
export LC_ALL=C
4047
fi
4148
fi
42-
43-
set -xuve
44-
job_name_ptrn='%CURRENT_LOGDIR%/%JOBNAME%'
4549
echo $(date +%s) > ${job_name_ptrn}_STAT_%FAIL_COUNT%
4650
4751
###################
4852
# AS CHECKPOINT FUNCTION
4953
###################
5054
# Creates a new checkpoint file upon call based on the current numbers of calls to the function
51-
52-
AS_CHECKPOINT_CALLS=0
5355
function as_checkpoint {
5456
AS_CHECKPOINT_CALLS=$((AS_CHECKPOINT_CALLS+1))
5557
touch ${job_name_ptrn}_CHECKPOINT_${AS_CHECKPOINT_CALLS}
5658
}
59+
AS_CHECKPOINT_CALLS=0
5760
%EXTENDED_HEADER%
58-
61+
set -u
5962
""")
6063
"""Autosubmit Bash header."""
6164

6265
_AS_BASH_TAILER = dedent("""\
66+
__AS_CMD__
67+
r=$?
68+
69+
# Write the finish time in the job _STAT_
70+
echo $(date +%s) >> ${job_name_ptrn}_STAT_%FAIL_COUNT%
71+
72+
# If the user-provided script failed, we exit here with the same exit code;
73+
# otherwise, we let the execution of the tailer happen, where the _COMPLETED
74+
# file will be created.
75+
if [ $r -ne 0 ]; then
76+
exit $r
77+
fi
6378
%EXTENDED_TAILER%
6479
###################
6580
# Autosubmit tailer
@@ -89,25 +104,9 @@ def as_body(body: str) -> str:
89104
###################
90105
# Autosubmit job
91106
###################
92-
93-
r=0
94-
set +e
95-
bash -e <<"__AS_CMD__"
96-
set -xuve
97107
{body}
98-
__AS_CMD__
99108
100-
r=$?
101-
102-
# Write the finish time in the job _STAT_
103-
echo $(date +%s) >> ${{job_name_ptrn}}_STAT_%FAIL_COUNT%
104-
105-
# If the user-provided script failed, we exit here with the same exit code;
106-
# otherwise, we let the execution of the tailer happen, where the _COMPLETED
107-
# file will be created.
108-
if [ $r -ne 0 ]; then
109-
exit $r
110-
fi""")
109+
""")
111110

112111

113112
def as_tailer() -> str:

0 commit comments

Comments
 (0)