Bug 59001

Summary: if $command is looked at, it doesn't exec
Product: [Retired] Red Hat Linux Reporter: Joe Harrington <jhmail>
Component: tcshAssignee: Miloslav Trmač <mitr>
Status: CLOSED WORKSFORME QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: jhmail
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-08-18 16:01:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Joe Harrington 2002-01-29 03:10:08 UTC
Description of Problem:

If tcsh is invoked with "-" as argv[0][0] and with the -c option, the .login
file is sourced before the command specified by -c is run.  This happens, e.g.,
in /etc/X11/xdm/Xsession when it does exec -l $SHELL -c "gnome-session".

In this case, it is possible to look at, and possibly change, $command (the
command to be run by the shell).  However, if .login (or, presumably, any file
that is run in a login shell) references $command, the command is not run.  For
example:
echo $command > foobar
in the .login file will make the command not run.  This is a bug, since the man
page says that a command specified with -c will run, and does not mention this
behavior as making it not run.  Note that the -l portion of the man page says
that -l is only effective if it is the only argument, but this is not said about
the method mentioned above for getting a login shell.

Why look at $command in .login?  Why not just let it run when .login ends?
If the .login file execs something, say ssh-agent inside a suitably protecting
conditional, it had better exec the command the shell would run if the shell was
invoked with -c.  Otherwise, it must be invoked to run a login shell.  This
entails looking at $command.  If the look is negative and the exec doesn't
happen, the rest of .login runs. $command will nonetheless not run after .login
ends.

Version-Release number of selected component (if applicable):

tcsh-6.10-6

How Reproducible:

100%

Steps to Reproduce:
1. set up a bash shell script that does exec -l /bin/tcsh -c "date"
2. modify .login to look at $command
3. run the bash script

Actual Results:

the date is not printed

Expected Results:

the date is printed

Additional Information:

none

--jh--

Comment 1 Miloslav Trmač 2004-08-18 16:01:10 UTC
With tcsh-6.13-1 or 6.12-8:

$ cat ~/.login
echo $command > foobar
echo FOO
$ (exec -l /bin/tcsh -c date)
FOO
St srp 18 18:01:33 CEST 2004
$ cat foobar
date