On Wed, 27 Aug 2008 12:18, 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...)
>

I use this slab right near the top of my /etc/profile; it's a steal of the 
bash stuff that I found when I started using SuSE

# Check which shell is reading this file
case "$0" in
  *rbash*) is=bash ;;
  *bash*)  is=bash ;;
  *rksh*)  is=ksh  ;;
  *ksh*)   is=ksh  ;;
  *ash*)   is=ash  ;;
  *zsh*)   is=zsh  ;;
  *)       is=sh   ;;
esac

and copes with most known shells, even the useless ones.

Way back, when I had to distinguish ksh from sh, I used to have


if [ "$(id)" != '$(id)' ]
  then is=ksh
  else is=sh
fi

because the "$(id)" is magical on ksh but not on plain sh


_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to