Can a function only be called if its name is the first word of an expression, as is the case with aliases?
Or can it also be the nth word of an expression?
I can't emulate a use case that answers this question of mine.
I can't find a guide that answers this question of mine.
Being Italian, I find it difficult to find the right words on the Google search engine.
Can you also mention the source in the answer?
Thank you.
Update:
5 answers (including 1 deleted and 2 non-answers) despite the question received 2 unjustified negative votes. A question simple to understand, complete as it is and that does not need details, which if inserted anyway only confuse the concept. Despite my dissatisfaction with users' reactions and unkind comments, the @muru answer is the most correct one. Obviously things change in a for loop but it was implied, I've used bash for years too.
Your link answers my question: Function Definition Command, where there is a point that says:
"
The compound-command shall be executed whenever the function name is specified as the name of a simple command.
The operands to the command temporarily shall become the positional parameters during the execution of the compound-command; the special parameter '#' also shall be changed to reflect the number of operands. The special parameter 0 shall be unchanged. When the function completes, the values of the positional parameters and the special parameter '#' shall be restored to the values they had before the function was executed. If the special built-in return (see return) is executed in the compound-command, the function completes and execution shall resume with the next command after the function call.
"
Thank you @muru.
myfunction
any different from the arguments toanycommand
? What do you want to accomplish exactly?x=y z
, the functionz
is called, but it is the second word.eval z
, the functionz
is again the second word. It is called without any expansion or removal of other words or fields for processing. The expression can be made arbitrarily long:eval eval eval eval eval z
. It demonstrates that functions do not have to be the first word in an expression to be called, though I don't see any purpose for it.