Skip to content
Discussion options

You must be logged in to vote

The answer to the riddle is that the . and source commands in ksh93 read and parse the entire dot script before executing it, in a single sh_eval call here:

sh_eval(iop,sh_isstate(SH_PROFILE)?SH_FUNEVAL:0);

Since everything is parsed before any alias command 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_aliases to enable it. After that it will act like other non-ksh93 shells.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by McDutchie
Comment options

You must be logged in to vote
1 reply
@McDutchie
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants