github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/is-null.md (about) 1 # `is-null` 2 3 > Checks if a variable is null or undefined 4 5 ## Description 6 7 `is-null` checks if a variable is null or undefined. If multiple variables are 8 passed in `is-null`'s parameters, the exit number will be a count of the number 9 of non-null variables checked. 10 11 `is-null` is intended to be run non-interactively, where it doesn't write to 12 stdout but instead communicates its results via exit number. However if stdout 13 is a TTY `is-null` will additionally write to the terminal. 14 15 The following conditions are considered "null" by `is-null`: 16 17 * a variable not being defined 18 * a property not existed, eg an object key or array index 19 * any other error reading from a variable 20 * or the value of the variable or property being the data-type `null` or a 21 value of null. 22 23 Zero length strings, strings containing the word "null" and numeric data types 24 (eg `num`, `int`, `float` with the value of `0`) are all **not null**. 25 26 ## Usage 27 28 ``` 29 is-null variable_name... -> <stdout> 30 ``` 31 32 ## Examples 33 34 **Interactive output:** 35 36 ``` 37 » $baz = "" 38 » is-null foo bar baz 39 foo: undefined or null 40 bar: undefined or null 41 baz: defined and not null 42 ``` 43 44 **None interactive output:** 45 46 ``` 47 if { is-null foobar } then { 48 out "baz is undefined" 49 } 50 ``` 51 52 ## See Also 53 54 * [Reserved Variables](../user-guide/reserved-vars.md): 55 Special variables reserved by Murex 56 * [Variable and Config Scoping](../user-guide/scoping.md): 57 How scoping works within Murex 58 * [`??` Null Coalescing Operator](../parser/null-coalescing.md): 59 Returns the right operand if the left operand is empty / undefined (expression) 60 * [`export`](../commands/export.md): 61 Define an environmental variable and set it's value 62 * [`global`](../commands/global.md): 63 Define a global variable and set it's value 64 * [`set`](../commands/set.md): 65 Define a local variable and set it's value 66 67 <hr/> 68 69 This document was generated from [builtins/core/typemgmt/isnull_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/typemgmt/isnull_doc.yaml).