Ah, thanks. - So that's unreliable if one is running another ksh version;
I seem to get a different output of '1' with Version JM 93t+ 2009-05-01

Janis

----------------------------------------
> Date: Sat, 17 Dec 2011 19:00:17 +0100
> From: [email protected]
> To: [email protected]
> Subject: Re: [ast-users] Is there a simple way for a script to know if it's 
> run as a script (ksh script ) or sourced (. script) ?
>
> Janis Papanagnou:
> [ snip ]
> > where shell program sh_level is
> >
> > $ cat sh_level
> > printf "'%s'\n" "${.sh.level}"
> > (( $1> 0 ))&& . ./sh_level $(( $1 - 1 ))
> >
> > # Version JM 93t+ 2009-05-01
> >
> > Under what condition will you get a "0" ?
>
> Hi Janis,
>
> At the prompt level:
>
> $ . ./sh_level
> '0'
> -ksh: .: line 2: > 0 : arithmetic syntax error
>
> $ print ${.sh.version}
> Version JM 93u+ 2011-06-21
>
> Cheers,
> Henk
>
> >> Date: Sat, 17 Dec 2011 01:23:10 +0100
> >> From: [email protected]
>
> [...]
> >> .sh.level == 0 indicates an interactive shell
> _______________________________________________
> ast-users mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-users
                                          
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to