github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/variables/self.md (about) 1 # `SELF` (json) 2 3 > Meta information about the running scope. 4 5 ## Description 6 7 `SELF` returns information about the functional scope that the code is running 8 inside. Such as whether that functions STDOUT is a TTY, running in the 9 background or a method. 10 11 A 'scope' in Murex is a collection of code blocks to which variables and 12 config are persistent within. In Murex, a variable declared inside an `if` or 13 `foreach` block will be persistent outside of their blocks as long as you're 14 still inside the same function. 15 16 Please see scoping document (link below) for more information on scoping. 17 18 This is a reserved variable so it cannot be changed. 19 20 21 22 ## Examples 23 24 ``` 25 » function example { $SELF } 26 » example 27 { 28 "Background": false, 29 "Interactive": true, 30 "Method": false, 31 "Module": "murex/shell", 32 "Not": false, 33 "Parent": 834, 34 "Scope": 834, 35 "TTY": true 36 } 37 ``` 38 39 ## Detail 40 41 ### Background (bool) 42 43 A boolean value to identify whether the current scope is running in the 44 background for foreground. 45 46 ### Interactive (bool) 47 48 A boolean value to describe whether the current scope is running interactively 49 or not. 50 51 An interactive scope is one where the shell prompt is running _and_ the scope 52 isn't running in the background. Shell scripts are not considered interactive 53 terminals even though they might have interactive element in their code. 54 55 ### Method (bool) 56 57 A boolean value to describe whether the current scope is a method (ie being 58 called mid-way or at the end of a pipeline). 59 60 ### Module (str) 61 62 This will be the module string for the current scope. 63 64 ### Not (bool) 65 66 A boolean value which represents whether the function was called with a bang- 67 prefix or not. 68 69 ### Parent (num) 70 71 This is the function ID of the parent function that created the scope. In 72 some instances this will be the same value as scope FID. However if in doubt 73 then please using **Scope** instead. 74 75 ### Scope (num) 76 77 The scope value here returns the function ID of the top level function in the 78 scope. 79 80 ### TTY (bool) 81 82 A boolean value as to whether STDOUT is a TTY (ie are we printing to the 83 terminal (TTY) or a pipe?) 84 85 ## Synonyms 86 87 * `self` 88 * `SELF` 89 90 91 ## See Also 92 93 * [Interactive Shell](../user-guide/interactive-shell.md): 94 What's different about Murex's interactive shell? 95 * [Modules and Packages](../user-guide/modules.md): 96 An introduction to Murex modules and packages 97 * [Pipeline](../user-guide/pipeline.md): 98 Overview of what a "pipeline" is 99 * [Reserved Variables](../user-guide/reserved-vars.md): 100 Special variables reserved by Murex 101 * [Variable and Config Scoping](../user-guide/scoping.md): 102 How scoping works within Murex 103 * [`function`](../commands/function.md): 104 Define a function block 105 * [`json`](../types/json.md): 106 JavaScript Object Notation (JSON) 107 * [`string` (stringing)](../types/str.md): 108 string (primitive) 109 110 <hr/> 111 112 This document was generated from [gen/variables/SELF_doc.yaml](https://github.com/lmorg/murex/blob/master/gen/variables/SELF_doc.yaml).