Bug 59001 - if $command is looked at, it doesn't exec
Summary: if $command is looked at, it doesn't exec
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: tcsh
Version: 7.2
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Miloslav Trmač
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-01-29 03:10 UTC by Joe Harrington
Modified: 2007-04-18 16:39 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-08-18 16:01:10 UTC
Embargoed:


Attachments (Terms of Use)

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



Note You need to log in before you can comment on or make changes to this bug.