Bash Nameref: Mutate Function Arguments (Pointer-Like Behavior)
Read OriginalThis article covers Bash's nameref feature (local -n) introduced in Bash 4.3, which allows functions to mutate variables passed by name, similar to pointers. It includes a TL;DR, use case example from dotfiles for skipping package installations, and warnings about circular name references. The technique helps avoid subshells and global variables, especially when returning arrays. Targeted at shell scripters looking for advanced Bash techniques.
Comments
No comments yet
Be the first to share your thoughts!
Browser Extension
Get instant access to AllDevBlogs from your browser
Top of the Week
No top articles yet