LINENO is set to zero during the execution of aliases or commands in 'eval'. This behaviour is different from that of other shells.
#! /usr/bin/env mksh alias showlineno='echo $LINENO' eval 'echo $LINENO' showlineno Actual output: 0 0 Expected output: 3 (or 1) 4 This behaviour seems to be inherited from pdksh, but no other shell has it. Several shells (dash, yash, zsh in native mode, ksh93) start counting from 1 when executing an 'eval', as if they considered it a separate script, so they output 1 for the eval. But all shells output 4 for the alias. Another test script: printf "$LINENO " printf "$LINENO " eval ' printf "$LINENO " printf "$LINENO " printf "$LINENO " ' printf "$LINENO\n" Output on various shells: mksh: 1 2 0 0 0 6 lksh: 1 2 0 0 0 6 pdksh: 1 2 0 0 0 6 AT&T ksh88: 1 2 3 3 3 6 AT&T ksh93: 1 2 1 2 3 6 bash: 1 2 5 6 7 6 (?!) FreeBSD sh: 1 2 1 2 3 6 dash: 1 2 1 2 3 6 yash: 1 2 1 2 3 6 zsh (native): 1 2 1 2 3 6 zsh (sh): 1 2 3 3 3 6 (like ksh88) (Looks like I may also have to tell bug-bash that the bash behaviour is weird, and zsh-workers that zsh's sh mode is not emulating any current sh). HTH, - M.