I do not think that someone has fully answered the question. He did not ask if he could repeat the lines in order. Rather, the question author wants to know if he can simulate the behavior of a function pointer.
There are several answers that are very similar to what I would do, and I want to expand it with another example.
From the author:
function x() { echo "Hello world" } function around() { echo "before" ($1) <------ Only change echo "after" } around x
To expand this, we will have the x echo "Hello world: $ 1" function to show when the function actually executes. We will pass a string that is the name of the function "x":
function x() { echo "Hello world:$1" } function around() { echo "before" ($1 HERE) <------ Only change echo "after" } around x
To describe this, the string "x" is passed to the function around (), which echos "before" calls the function x (via the variable $ 1, the first parameter passed), passing the argument "HERE", finally the echo after.
As another, it is a methodology for using variables as function names. The variables actually contain a string, which is the name of the function, and (the variable $ arg1 arg2 ...) calls the function that passes the arguments. See below:
function x(){ echo $3 $1 $2 <== just rearrange the order of passed params } Z="x"
gives: 30 10 20, where we executed a function with the name "x" stored in the variable Z, and passed parameters 10 20 and 30.
Above, where we refer to functions, assigning variable names to functions, so that we can use a variable instead of actually knowing the function name (which is similar to what you could do in a very classic situation with a function pointer in c to generalize the program stream, but pre-selecting function calls that you will create based on command line arguments).
In bash, these are not function pointers, but variables that reference function names that you later use.