Skip to content

Commit 8fee50b

Browse files
committed
moved section on empty env vars from getting_started to common_pitfalls
1 parent 9c16777 commit 8fee50b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

mkdocs/docs/HPC/linux-tutorial/common_pitfalls.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,29 @@ But, this is tedious, and you can prevent errors by simply colouring
4949
within the lines and not using spaces in filenames.
5050

5151
### Missing/mistyped environment variables
52+
53+
A common pitfall is the (accidental) use of non-defined variables.
54+
Contrary to what you may expect, this does *not* result in error
55+
messages, but the variable is considered to be *empty* instead.
56+
57+
This may lead to surprising results, for example:
58+
<pre><code>$ <b>export WORKDIR=/tmp/test</b>
59+
$ <b>pwd</b>
60+
/user/home/gent/vsc400/vsc40000
61+
$ <b>echo $HOME</b>
62+
/user/home/gent/vsc400/vsc40000
63+
</code></pre>
64+
65+
!!! tip
66+
For job scripts, use `set -e -u` to avoid using empty variables accidentally.
67+
68+
The `-e` option will result in the script getting stopped if any command
69+
fails.
70+
71+
The `-u` option will result in the script getting stopped if empty
72+
variables are used. (see <https://ss64.com/bash/set.html> for a more
73+
detailed explanation and more options)
74+
5275
If you use a command like `rm -r` with environment variables you need to
5376
be careful to make sure that the environment variable exists. If you
5477
mistype an environment variable then it will resolve into a blank string.

0 commit comments

Comments
 (0)