[comp.unix.shell] How does one learn arg0 in csh

ruck@reef.cis.ufl.edu (John Ruckstuhl) (11/28/90)

I'd like to test if a csh is a login shell in ~/.cshrc.  In a Bourne
shell, I can look at $0 and see "-sh" , but in csh, $0 substitutes "the 
name of the file from which command input is being read" which is an
error in an interactive csh.

"login" documentation says: Argument 0 of the command interpreter is the
name of the command interpreter with a leading dash ('-') prepended.

I am aware that if the csh !is! the login shell, then ~/.login will be 
sourced.

I am using the csh shipped with SunOS 4.1 on SPARCStation1+'s.
"what `which csh`" shows a lot of revision info -- perhaps this line
identifies the version sufficiently:
        sh.c 1.22 89/05/22 SMI; from UCB 5.3 3/29/86

Thank you for your comments,
ruck
--
John R Ruckstuhl, Jr
University of Florida		ruck@cis.ufl.edu, uflorida!ruck

j_adams@hpfcbig.SDE.HP.COM (John Adams) (11/30/90)

The c-shell "prompt" varaible will be set if you have a login shell.  You
can test by:

   if ( $?prompt )

John Adams

ruck@reef.cis.ufl.edu (John Ruckstuhl) (12/03/90)

me> I'd like to test if a csh is a login shell in ~/.cshrc.  In a Bourne
me> shell, I can look at $0 and see "-sh" , but in csh, $0 substitutes "the 
me> name of the file from which command input is being read" which is an
me> error in an interactive csh.
me> "login" documentation says: Argument 0 of the command interpreter is the
me> name of the command interpreter with a leading dash ('-') prepended.
me> I am aware that if the csh !is! the login shell, then ~/.login will be 
me> sourced.

j_adams@hpfcbig.SDE.HP.COM (John Adams) writes:
>The c-shell "prompt" varaible will be set if you have a login shell.  You
>can test by:
>   if ( $?prompt )

Insufficient, I think.  prompt will also be set if one is in a subshell 
to the login shell, rather than in a login shell.

Thank you for your comments,
ruck
--
John R Ruckstuhl, Jr
University of Florida		ruck@cis.ufl.edu, uflorida!ruck

roger@wrs.com (Roger Rohrbach) (12/04/90)

ruck@reef.cis.ufl.edu (John Ruckstuhl) writes:

> I'd like to test if a csh is a login shell in ~/.cshrc.

  (This is really what your "Subject:" line should be.)  In an interactive
C shell, the "prompt" variable will be set.  This can be tested with

    if ($?prompt) then
	...
    endif

-- 
Roger Rohrbach                                  sun!wrs!roger    roger@wrs.com
- Eddie sez: ----------------------------------------------- (c) 1986, 1990 -.
|   {o >o                                                                     |
|    \ -) "Two men need one money, but one money needs no man."               |