Bug 1710925

Summary: exits with exit code 2 in kde.csh
Product: Red Hat Enterprise Linux 7 Reporter: chun-liang.lin
Component: kde-settingsAssignee: Jan Grulich <jgrulich>
Status: CLOSED DUPLICATE QA Contact: Desktop QE <desktop-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: admin, bkw1a, jgrulich, mboisver, toracat
Target Milestone: rcKeywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-02-12 09:02:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description chun-liang.lin 2019-05-16 15:06:57 UTC
Description of problem:

We must run the csh scripts with -e (csh exits if any invoked command terminates abnormally or yields a non-zero exit status)

the script exits in /etc/profile.d/kde.csh with exit code 2

For example :  csh -Xec '/bin/true && echo true'

Output : 
if ( -r /etc/profile.d/colorls.csh ) then
if ( 0 ) then
source /etc/profile.d/colorls.csh
endif
endif
end
if ( -r /etc/profile.d/kde.csh ) then
if ( 0 ) then
source /etc/profile.d/kde.csh

> echo $status
2

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

All of the RHEL 7 has the same issue. It's ok in RHEL 6.

How reproducible:

Steps to Reproduce:
1. Install the kde-settings packages in RHEL 7
2. run the command csh -Xec '/bin/true && echo true'
3. echo the $status

Actual results:

$status = 2

Expected results:

$status = 0

Additional info:

Comment 2 chun-liang.lin 2019-05-16 15:12:19 UTC
Check the script in /etc/profile.d/kde.csh

## When/if using prelinking, avoids use of kdeinit
if ( ! $?KDE_IS_PRELINKED ) then
  grep -qs -qs '^PRELINKING=yes' /etc/sysconfig/prelink && \
  setenv KDE_IS_PRELINKED 1
endif

The kde.csh In RedHat 6, 

## When/if using prelinking, avoids use of kdeinit
if ( -f /etc/sysconfig/prelink ) then
   set PRELINKING = `grep "^PRELINKING=" /etc/sysconfig/prelink | cut -d"=" -f2`
   if ( "$PRELINKING" == "yes" )  then
     if ( ! $?KDE_IS_PRELINKED ) setenv KDE_IS_PRELINKED 1
   endif
   unset PRELINKING
endif

The code in RedHat 6 should be the better one.

Comment 4 Thomas Klar 2019-08-30 12:56:54 UTC
I ran into this same problem:

RHEL 7.7

kde-settings-19-23.9.el7.noarch

[root@pc12894 ~]# tcsh -X
...
if [ ! -d /root/.local/share -a -w /root ] then
if: Expression Syntax.


Checking /etc/profile.d/kde.sh and kde.csh , the 2 files have the same if at the end:

# Fix the user-places.xbel error pop at first user login
if [ ! -d ${HOME}/.local/share -a -w ${HOME} ] then
    mkdir -p ${HOME}/.local/share
endif

That is bash syntax. I'm a bash guy, don't really know csh, but with some help from google, this syntax seems to work for the kde.csh :

if ( ! -d ${HOME}/.local/share && -w ${HOME} ) then
    mkdir -p ${HOME}/.local/share
endif

Comment 5 Akemi Yagi 2019-08-30 14:28:21 UTC
This bug is being tracked for 7.7 in RHBZ #1738491 .

Comment 6 Bryan Wright 2019-08-30 14:48:34 UTC
I'm seeing the same problem with the final "if" statement in /etc/profile.d/kde.csh.  This is fairly serious because it also prevents users' own login files from being processed: the error in kde.csh prevents the execution of subsequent scripts in the login process.

As noted above, the correct syntax should be:

# Fix the user-places.xbel error pop at first user login
if ( ! -d ${HOME}/.local/share && -w ${HOME} ) then
    mkdir -p ${HOME}/.local/share
endif