@@ -92,45 +92,47 @@ to, and trailing comments should be preceded by two spaces, as shown above.
92
92
Script String Lines
93
93
^^^^^^^^^^^^^^^^^^^
94
94
95
- Script strings are written verbatim to task job scripts so they should really
96
- be indented from the left margin:
95
+ Script strings are written verbatim to task job scripts.
96
+
97
+ .. code-block :: cylc
98
+
99
+ [runtime]
100
+ [[foo]]
101
+ script = echo "Hello, Mr. Thompson"
102
+
103
+ If using a triple-quoted string, any common leading whitespace is trimmed
104
+ using the logic of :py:func: `textwrap.dedent `. As such, it is recommended to
105
+ indent like any other triple-quoted string setting in Cylc:
97
106
98
107
.. code-block :: cylc
99
108
100
109
[runtime]
101
110
[[foo]]
102
111
# Recommended.
103
- post- script = """
104
- if [[ $RESULT == "bad" ]]; then
105
- echo Goodbye World!
112
+ script = """
113
+ if [[ " $RESULT" == "bad" ]]; then
114
+ echo " Goodbye World!"
106
115
exit 1
107
116
fi
108
117
"""
109
118
110
- Indentation is *mostly * ignored by the bash interpreter, but is useful for
111
- readability. It is *mostly * harmless to indent internal script lines as if
112
- part of the Cylc syntax, or even out to the triple quotes:
119
+ The example above would result in the following being written to the job
120
+ script:
113
121
114
- .. code-block :: cylc
122
+ .. code-block :: bash
115
123
116
- [runtime]
117
- [[foo]]
118
- # OK, but...
119
- post-script = """if [[ $RESULT == "bad" ]]; then
120
- echo Goodbye World!
121
- exit 1
122
- fi"""
124
+ if [[ " $RESULT " == " bad" ]]; then
125
+ echo " Goodbye World!"
126
+ exit 1
127
+ fi
123
128
124
- On parsing the triple quoted value, Cylc will remove any common leading
125
- whitespace from each line using the logic of
126
- `Python's textwrap.dedent <https://docs.python.org/2/library/textwrap.html#textwrap.dedent >`_
127
- so the script block would end up being the same as the previous example.
128
- However, you should watch your line length (see :ref: `Line Length `) when you
129
- have many levels of indentations.
129
+ .. tip ::
130
130
131
- .. note ::
131
+ Take care when indenting here documents (aka heredocs) to match the
132
+ common leading whitespace.
132
133
133
- Take care when indenting here documents:
134
+ For the following example, each line in ``log.txt `` would end up with
135
+ 4 leading white spaces:
134
136
135
137
.. code-block :: cylc
136
138
@@ -143,8 +145,7 @@ have many levels of indentations.
143
145
_EOF_
144
146
"""
145
147
146
- Each line in ``log.txt `` would end up with 4 leading white spaces. The
147
- following will give you lines with no white spaces.
148
+ The following will give you lines with no white spaces:
148
149
149
150
.. code-block :: cylc
150
151
0 commit comments