unintuitive, but maybe correctthepsychotronAugust 30 2005, 13:10:27 UTC
I did a quick look through the bash man page and found:
"The first word of each simple command, if unquoted, is checked to see if it has an alias. If so, that word is replaced by the text of the alias."
"Aliases are expanded when a command is read, not when it is executed."
"Aliases are expanded when a function definition is read, not when the function is executed, because a function definition is itself a compound command."
Actually substituting the name of the function in the function declaration would seem a reasonable interpretation of these rules. It may not be possible to tell at the time of the substitution whether it is a function declaration or a simple command because the substitution itself could change the meaning of the statement to one or the other. I haven't yet looked at what the documentation for other shells say on this.
Comments 6
Reply
need i reiterate what a dork you are? :p
Reply
"The first word of each simple command, if unquoted, is checked to see if it has an alias. If so, that word is replaced by the text of the alias."
"Aliases are expanded when a command is read, not when it is executed."
"Aliases are expanded when a function definition is read, not when the function is executed, because a function definition is itself a compound command."
Actually substituting the name of the function in the function declaration would seem a reasonable interpretation of these rules. It may not be possible to tell at the time of the substitution whether it is a function declaration or a simple command because the substitution itself could change the meaning of the statement to one or the other. I haven't yet looked at what the documentation for other shells say on this.
Reply
Reply
Reply
*crazyface*
Reply
Leave a comment