I want this:

$ ssh nopathcsh@lo 'echo $path'
/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games

To return this:

/usr/bin /bin

I have tried changing and removing .login and .cshrc, but that seems to have no effect. These seem only to have effect if the shell is interactive.

The user nopathcsh has /bin/csh as login shell.

  • Using set path=(/usr/bin /bin) in ~/.login and csh -l <<< 'echo $path' works for me...? – Jeff Schaller Jun 20 '19 at 16:59
  • How can I ask ssh nopathcsh@lo 'echo $path' to run csh -l? – Ole Tange Jun 20 '19 at 17:07
  • I don't have csh as a login shell, so I was emulating it. If the nopathcsh user has csh as their login shell, then my assumption would be that ~/.login would be the right place. But I wasn't sure, so I thought I'd check against what you had tested. – Jeff Schaller Jun 20 '19 at 17:09
  • @JeffSchaller The ssh nopathcsh@lo 'echo $path' is non-optional and cannot be changed. You can change .ssh/* or .login/.cshrc or /etc/*. – Ole Tange Jun 20 '19 at 17:09
  • I suppose a more direct comment would be: what happens when you put set path=(/usr/bin /bin) in ~nopathcsh/.login? – Jeff Schaller Jun 20 '19 at 17:13

It appears my /bin/csh is really tcsh and even when called as /bin/csh it thinks it should read .tcshrc (which baffles me: if I call csh I expect to get csh not tcsh).

Removing .tcshrc made it respect .cshrc (but not .login).

|improve this answer|||||
  • Interesting; my "csh" is "tcsh" also, and with a misleading ~/.tcshrc file and a correct ~/.login, .~/login still prevails in my testing. – Jeff Schaller Jun 20 '19 at 17:25
  • I think we can conclude csh works in mysterious ways. – Ole Tange Jun 20 '19 at 17:29
  • 1
    why are you expecting that? the tcsh(1) manpage clearly tells that ~/.tcshrc will be tried first, no matter what the interpreter is called. .login will only be read by a login shell --ie a shell with its argv[0] starting with a dash. ssh will start such a "login shell" only when no command was given. – mosvy Jun 21 '19 at 3:38
  • @mosvy I naively expected tcsh to be a drop-in replacement for csh when called as csh. I am happy that the incompatibility is at least documented. – Ole Tange Jun 21 '19 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.