diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-06-02 12:15:47 +0200 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-06-02 12:17:02 +0200 |
commit | 9bd8cdf2ecc2b60f873b393122b19985cbc4587c (patch) | |
tree | a4e0ad7e2824e24b187525fc3c51f8d382d1aceb /Null substitution.md | |
parent | a61d928b279c5c508aca3bfc7cb14d810c3d75de (diff) |
vault backup: 2025-06-02 12:15:47
Diffstat (limited to 'Null substitution.md')
-rw-r--r-- | Null substitution.md | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Null substitution.md b/Null substitution.md new file mode 100644 index 0000000..276a2e6 --- /dev/null +++ b/Null substitution.md @@ -0,0 +1,25 @@ +--- +tags: + - bash +--- +[[Bash]] [[Process substition (tmp file)]] [[Parameter subsitution]] + +--- +[This](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02) page contains a table with [[Parameter subsitution]] + +When we want to expand a variable into an argument to a command but the variable is empty it will expand to **an empty string**. This is often unwanted, we just want `null` which is removed from the command-line. + +*Example* +``` +openstack server delete server "${waitFlag}" +``` +if `waitFlag` is empty this will become: +``` +openstack server delete server '' +``` +which results in an error. + +This is where we can use `null substitution`: +``` +openstack server delete server "${waitFlag:+$waitFlag}" +```
\ No newline at end of file |