David Korn:
> You should be able to use the variable SHLVL for this. The value is
> incremented if the script is run by a separate shell or as a script.
>
> David Korn
> [email protected]
Hi David,
Thanks for looking into this.
I looked at SHLVL. It's not a discriminator when you source one script
from another:
Sample 1: "script-a"
#!/bin/ksh
ps -o pid= | read pid
print script-a:$LINENO : SHLVL=${SHLVL} pid=$pid : arg0=$0 argv=$@ :
. ./script-b
Sample 2: "script-b"
#!/bin/ksh
ps -o pid= | read pid
print script-b:$LINENO : SHLVL=${SHLVL} pid=$pid : arg0=$0 argv=$@ :
Sample 3: "Output from ksh script-a"
script-a:3 : SHLVL=2 pid=1666816 : arg0=script-a argv= :
script-b:3 : SHLVL=2 pid=1666816 : arg0=script-a argv= :
So far, the only sure method is knowing the name it will be invoked as,
and compare that to $0 -- this works in both ksh88(sun) and ksh93.
Cheers,
Henk
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users