On Ubuntu 22.10, I noticed that some system shipped environments initialization scripts have syntax or logic errors as follows:
werner@X10DAi:~$ . /etc/profile.d/debuginfod.csh
bash: debuginfod.csh.save: line 17: syntax error: unexpected end of file
werner@X10DAi:~$ . /etc/profile.d/gawk.csh
bash: alias: gawkpath_default: not found
bash: alias: `unsetenv AWKPATH; setenv AWKPATH `gawk -v x': invalid alias name
bash: alias: gawkpath_prepend: not found
bash: alias: `if (! $?AWKPATH) setenv AWKPATH ""; if ($AWKPATH ': invalid alias name
bash: alias: gawkpath_append: not found
bash: alias: `if (! $?AWKPATH) setenv AWKPATH ""; if ($AWKPATH ': invalid alias name
bash: alias: gawklibpath_default: not found
bash: alias: `unsetenv AWKLIBPATH; setenv AWKLIBPATH `gawk -v x': invalid alias name
bash: alias: gawklibpath_prepend: not found
bash: alias: `if (! $?AWKLIBPATH) setenv AWKLIBPATH ""; if ($AWKLIBPATH ': invalid alias name
bash: alias: gawklibpath_append: not found
bash: alias: `if (! $?AWKLIBPATH) setenv AWKLIBPATH ""; if ($AWKLIBPATH ': invalid alias name
werner@X10DAi:~$ . /etc/profile.d/vte.csh
bash: vte.csh.save: line 19: syntax error near unexpected token `!'
bash: vte.csh.save: line 19: `if ( ! $?prompt | ! $?tcsh | ! $?TERM | ! $?VTE_VERSION ) exit'
Below are the contents of the above scripts:
werner@X10DAi:~$ cat debuginfod.csh
# $HOME/.login* or similar files may first set $DEBUGINFOD_URLS.
# If $DEBUGINFOD_URLS is not set there, we set it from system *.url files.
# $HOME/.*rc or similar files may then amend $DEBUGINFOD_URLS.
# See also [man debuginfod-client-config] for other environment variables
# such as $DEBUGINFOD_MAXSIZE, $DEBUGINFOD_MAXTIME, $DEBUGINFOD_PROGRESS.
if (! $?DEBUGINFOD_URLS) then
set prefix="/usr"
set DEBUGINFOD_URLS=`sh -c 'cat "$0"/*.urls; :' "/etc/debuginfod" 2>/dev/null | tr '\n' ' '`
if ( "$DEBUGINFOD_URLS" != "" ) then
setenv DEBUGINFOD_URLS "$DEBUGINFOD_URLS"
else
unset DEBUGINFOD_URLS
endif
unset prefix
endif
werner@X10DAi:~$ cat gawk.csh.save
alias gawkpath_default 'unsetenv AWKPATH; setenv AWKPATH `gawk -v x=AWKPATH "BEGIN {print ENVIRON[x]}"`'
alias gawkpath_prepend 'if (! $?AWKPATH) setenv AWKPATH ""; if ($AWKPATH == "") then; unsetenv AWKPATH; setenv AWKPATH `gawk -v x=AWKPATH "BEGIN {print ENVIRON[x]}"`; endif; setenv AWKPATH "\!*"":$AWKPATH"'
alias gawkpath_append 'if (! $?AWKPATH) setenv AWKPATH ""; if ($AWKPATH == "") then; unsetenv AWKPATH; setenv AWKPATH `gawk -v x=AWKPATH "BEGIN {print ENVIRON[x]}"`; endif; setenv AWKPATH "$AWKPATH"":\!*"'
alias gawklibpath_default 'unsetenv AWKLIBPATH; setenv AWKLIBPATH `gawk -v x=AWKLIBPATH "BEGIN {print ENVIRON[x]}"`'
alias gawklibpath_prepend 'if (! $?AWKLIBPATH) setenv AWKLIBPATH ""; if ($AWKLIBPATH == "") then; unsetenv AWKLIBPATH; setenv AWKLIBPATH `gawk -v x=AWKLIBPATH "BEGIN {print ENVIRON[x]}"`; endif; setenv AWKLIBPATH "\!*"":$AWKLIBPATH"'
alias gawklibpath_append 'if (! $?AWKLIBPATH) setenv AWKLIBPATH ""; if ($AWKLIBPATH == "") then; unsetenv AWKLIBPATH; setenv AWKLIBPATH `gawk -v x=AWKLIBPATH "BEGIN {print ENVIRON[x]}"`; endif; setenv AWKLIBPATH "$AWKLIBPATH"":\!*"'
werner@X10DAi:~$ cat vte.csh.save
# Copyright © 2019 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <
https://www.gnu.org/licenses/>.
#
# Red Hat Author(s): Carlos Santos
# exit if non-interactive, csh, no terminal or old VTE versions
if ( ! $?prompt | ! $?tcsh | ! $?TERM | ! $?VTE_VERSION ) exit
switch($TERM)
case xterm*:
alias precmd 'echo -n "\e]7;file://$HOST"; /usr/libexec/vte-urlencode-cwd; echo -n "\e\\"'
endsw
I'm not familiar with these csh syntax in them. Any tips to fix these problems?
Regards,
Zhao