exec /bin/tcsh produces a “if: Expression Syntax.” error


https://unix.stackexchange.com/questions/538329/exec-bin-tcsh-produces-a-if-expression-syntax-error

 

We have two servers: test box with Oracle Linux 7.6 and production box with Oracle Linux 7.7.

Running the exec /bin/tcsh command produces two different results.

On the test server:

# exec /bin/tcsh # 

No errors; however, on the production server:

# exec /bin/tcsh if: Expression Syntax. # 

We thought that there was an issue with the tcsh package on the production box and uninstalled/re-installed it but doing this did not resolve the issue. Any thoughts/suggestions as to what else we can try to resolve this issue?

One of the comments suggested adding -V to the command. Here are the last few lines of the output:

if ( $?QT_PLUGIN_PATH ) then if ( "${QT_PLUGIN_PATH}" !~ *${libdir}/kde4/plugins* ) then else end if [ ! -d ${HOME}/.local/share -a -w ${HOME} ] then if: Expression Syntax. 

There is a test server in which the exec command does not abend. Here's the -V output for the same line above:

if ( ! -d ${HOME}/.local/share ) then 

The only different is the -a -w ${HOME}

 

 

 

解决方案1:

Such an error message might be caused by a syntax error in the login scripts executed by the tcsh shell:

  • system-wide /etc/csh.cshrc
  • system-wide /etc/csh.login
  • user-specific ~/.cshrc
  • user-specific ~/.login

In Bourne/POSIX-style shells, the if statement is typically if [ condition ]; then ... else ... fi, but csh and tcsh express it as if (condition) then ... else ... endif. If you're used to Bourne/POSIX-style scripting, it is easy to type fi instead of endif when scripting for tcsh.

 

解决方案2:

1
 

The answer is that there is a bug in the kde-settings package. There is bourne-shell code in kde.csh.

We decided to perform the work-around and edited the /etc/profile.d/kde.csh file in the following manner:

original line: if [ ! -d ${HOME}/.local/share -a -w ${HOME} ]

edited line: if ( ! -d ${HOME}/.local/share && -w ${HOME} )

Version-Release number of selected component (if applicable): kde-settings-19-23.9.el7.noarch

This is the version that is installed on the server. There is an update available, which was not installed, kde-settings-19-23.10. Here's the link to the bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1738491.


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM