Bug 487064

Summary: /etc/profile.d/vim.csh breaks 'tcsh -e' scripts
Product: Red Hat Enterprise Linux 5 Reporter: Jeff Bastian <jbastian>
Component: vimAssignee: Karsten Hopp <karsten>
Status: CLOSED ERRATA QA Contact: BaseOS QE <qe-baseos-auto>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.3CC: pknirsch, psplicha, rbiba
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 578795 1523503 (view as bug list) Environment:
Last Closed: 2009-06-22 17:27:48 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:
Bug Depends On:    
Bug Blocks: 453798, 1523503, 1523506    

Description Jeff Bastian 2009-02-23 22:49:45 UTC
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 14:57:28 UTC
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 09:00:20 UTC
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 17:27:48 UTC
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