Bug 59001 - if $command is looked at, it doesn't exec
Summary: if $command is looked at, it doesn't exec
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: tcsh   
(Show other bugs)
Version: 7.2
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Miloslav Trmač
QA Contact: David Lawrence
Depends On:
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:
Story Points: ---
Clone Of:
Last Closed: 2004-08-18 16:01:10 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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
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

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


How Reproducible:


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:



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)
St srp 18 18:01:33 CEST 2004
$ cat foobar

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