Bug 59001 - if $command is looked at, it doesn't exec
if $command is looked at, it doesn't exec
Status: CLOSED WORKSFORME
Product: Red Hat Linux
Classification: Retired
Component: tcsh (Show other bugs)
7.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Miloslav Trmač
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-01-28 22:10 EST by Joe Harrington
Modified: 2007-04-18 12:39 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-08-18 12:01:10 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Joe Harrington 2002-01-28 22:10:08 EST
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 12:01:10 EDT
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.