Bug 487064 - /etc/profile.d/vim.csh breaks 'tcsh -e' scripts
/etc/profile.d/vim.csh breaks 'tcsh -e' scripts
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: vim (Show other bugs)
5.3
All Linux
medium Severity medium
: rc
: ---
Assigned To: Karsten Hopp
BaseOS QE
:
Depends On:
Blocks: 453798
  Show dependency treegraph
 
Reported: 2009-02-23 17:49 EST by Jeff Bastian
Modified: 2013-04-12 16:06 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 578795 (view as bug list)
Environment:
Last Closed: 2009-06-22 13:27:48 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 Jeff Bastian 2009-02-23 17:49:45 EST
Description of problem:
/etc/profile.d/vim.csh uses /usr/bin/[ instead of normal csh syntax for testing.  This breaks scripts that use 'tcsh -e' (see bug 453798 comment 14)

Here is a test script that breaks:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/tcsh -e

echo testing tcsh -e
grep foo /dev/null
echo should not get this far
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It should print 'testing tcsh -e' and then exits, but it prints nothing.  After applying the patch to fix bug 453798, run as root
   tcsh -Ve -c "/bin/echo hi"
and it'll get as far as the 2nd line in /etc/profile.d/vim.csh
   [ `/usr/bin/id -u` -gt 100 ] && alias vi vim

It quits here because root's uid is 0 so this returns 1 as an error.


The /etc/profile.d/vim.csh script should be
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( -x /usr/bin/id ) then
    if ( "`/usr/bin/id -u`" > 100 ) then
        alias vi vim
    endif
endif
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With this vim.csh script, the above tests succeed.


Version-Release number of selected component (if applicable):
vim-X11-7.0.109-4.el5_2.4z.x86_64
vim-common-7.0.109-4.el5_2.4z.x86_64
vim-enhanced-7.0.109-4.el5_2.4z.x86_64
vim-minimal-7.0.109-4.el5_2.4z.x86_64


How reproducible:
Every time

Steps to Reproduce:
1. /bin/tcsh -Ve -c "/bin/echo hi"
  
Actual results:
The last lines of output are
[ -x /usr/bin/id ] || exit
[ `/usr/bin/id -u` -gt 100 ] && alias vi vim

Expected results:
The last lines of output should be:
/bin/echo hi
hi

Additional info:
Comment 5 Petr Šplíchal 2009-05-29 10:57:28 EDT
Unfortunately, even with the fixed vim, tcsh -e does not succeed
when id returns an empty string. The following is displayed:

    if ( $uid > 99 && "`id -gn`" == "`id -un`" ) then

Seems, /etc/csh.cshrc needs some touches as well. I can't see any
problem on that line though...

When I removed the whole umask section, tcsh -e still failed. This
time because of problem in /etc/profile.d/lang.csh :(
Comment 6 Petr Šplíchal 2009-06-04 05:00:20 EDT
Taking back the last comment, there was a bug in the test case.
Should be ok together with fixed initscripts package.
See bug 453798 for more details (the lang.csh issue).
Comment 10 errata-xmlrpc 2009-06-22 13:27:48 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-1117.html

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