-
|
Yall, I got something I don't understand, must be me mis-reading the docco, yet after multiple read I still don't get it. This is about non recursive alias, yet it looks like some recursion prevention is applied. Apparently the 2 'e' invocation are not found even though there is no recursion here. again the 'e' inside the sourced file is not found, but the post-source is ok in interactive mode. Why this difference. Note that bash behave the same, so I am sure I am wrong somewhere but don't know where. Thanx in advance for any pointers. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
FWIW zsh behave differently The difference here is |
Beta Was this translation helpful? Give feedback.
-
|
The answer to the riddle is that the ksh/src/cmd/ksh93/bltins/misc.c Line 330 in 0818a7d Since everything is parsed before any As for bash, it has alias expansion disabled for scripts by default; you have to run it in POSIX mode or explicitly |
Beta Was this translation helpful? Give feedback.
-
|
Jeez I lost sight of this one, I'd better rely on $ expansion then @McDutchie for your explanations. |
Beta Was this translation helpful? Give feedback.
The answer to the riddle is that the
.andsourcecommands in ksh93 read and parse the entire dot script before executing it, in a singlesh_evalcall here:ksh/src/cmd/ksh93/bltins/misc.c
Line 330 in 0818a7d
Since everything is parsed before any
aliascommand is executed, such aliases are not expanded unless defined outside the dot script first. This behaviour is currently unique to ksh93, but POSIX explicitly allows it.As for bash, it has alias expansion disabled for scripts by default; you have to run it in POSIX mode or explicitly
shopt -s expand_aliasesto enable it. After that it will act like other non-ksh93 shells.