Hi Norman --

Norman Ramsey wrote:
> 
> In my new job, there's code in /etc/profile that contains a bash-ism:
> it's a test to see if the shell is a login shell.  From a quick google
> search and perusal of the ksh man page, I can't see any obvious way
> to see from within the shell if it is a login shell, let alone anything
> that is portable across ksh and bash.   (If you ask me a non-login shell
> has no business reading /etc/profile anyway, but people do the durndest
> things...)

By definition, a login shell has "-" as the first character of $0. The
following test should work for both ksh and bash:

  if [[ $0 == -* ]]; then echo "This is a login shell"; fi

--
Ron Isaacson
Morgan Stanley
[EMAIL PROTECTED] / (212) 276-1144
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to