Wednesday, October 26, 2022

[SOLVED] Anonymous functions in shell scripts

Issue

Is it possible to create something analogous to an anonymous function whose value can be assigned to an array element and later called? I can't seem to find a way to do this in a bash script but perhaps there's a workaround.


Solution

Short answer: No.

Long answer: Nooooooooooooo.

Complete answer: Functions in bash are not first-class objects, therefore there can be no such thing as an anonymous function in bash.



Answered By - Ignacio Vazquez-Abrams
Answer Checked By - Dawn Plyler (WPSolving Volunteer)