github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/user-guide/fileref.md (about) 1 # FileRef 2 3 > How to track what code was loaded and from where 4 5 ## Description 6 7 Every function, event, autocompletion and even variable is stored with which 8 file it was sourced, when it was loaded and what module it was loaded from. 9 This makes it trivial to identify buggy 3rd party code, malicious libraries, or 10 even just bugs in your own profiles and/or modules. 11 12 ``` 13 » runtime --functions -> [[ /agent/FileRef/ ]] 14 { 15 "Column": 5, 16 "Line": 5, 17 "Source": { 18 "DateTime": "2021-03-28T09:10:53.572197+01:00", 19 "Filename": "/home/lmorg/.murex_modules/murex-dev/murex-dev.mx", 20 "Module": "murex-dev/murex-dev" 21 } 22 } 23 24 » runtime --globals -> [[ /DEVOPSBIN/FileRef ]] 25 { 26 "Column": 1, 27 "Line": 0, 28 "Source": { 29 "DateTime": "2021-03-28T09:10:53.541952+01:00", 30 "Filename": "/home/lmorg/.murex_modules/devops/global.mx", 31 "Module": "devops/global" 32 } 33 } 34 ``` 35 36 ### Module Strings For Non-Module Code 37 38 #### Source 39 40 A common shell idiom is to load shell script files via `source` / `.`. When 41 this is done the module string (as seen in the `FileRef` structures described 42 above) will be `source/hash` where **hash** will be a unique hash of the file 43 path and load time. 44 45 Thus no two sourced files will share the same module string. Even the same file 46 but modified and sourced twice (before and after the edit) will have different 47 module strings due to the load time being part of the hashed data. 48 49 #### REPL 50 51 Any functions, variables, events, auto-completions, etc created manually, 52 directly, in the interactive shell will have a module string of `murex` and an 53 empty Filename string. 54 55 ## See Also 56 57 * [Modules and Packages](../user-guide/modules.md): 58 An introduction to Murex modules and packages 59 * [`[[ Element ]]`](../parser/element.md): 60 Outputs an element from a nested structure 61 * [`murex-package`](../commands/murex-package.md): 62 Murex's package manager 63 * [`runtime`](../commands/runtime.md): 64 Returns runtime information on the internal state of Murex 65 * [`source`](../commands/source.md): 66 Import Murex code from another file of code block 67 68 <hr/> 69 70 This document was generated from [gen/user-guide/fileref_doc.yaml](https://github.com/lmorg/murex/blob/master/gen/user-guide/fileref_doc.yaml).