Ensure csh syntax is used for C shell even if SHELL env var is unset.

We know we're running from C shell in perl-homedir.csh, so be
explicit rather than letting local::lib guess.

If the SHELL environment variable is not set, perl -Mlocal::lib is
fooled into emitting bourne shell syntax (e.g., export FOO=bar)
instead of csh syntax (setenv FOO bar).  This can be fatal to the
C shell possibly interrupting execution of a script before the
script has completed.

This (no SHELL variable set) can happen, for instance, when running a
cron job.

See also:
https://bugzilla.redhat.com/show_bug.cgi?id=2122359
https://issues.redhat.com/browse/RHEL-5545

Signed-off-by: John Hein <c0eh3p702@sneakemail.com>
This commit is contained in:
John Hein 2023-11-21 22:38:59 -07:00
parent 89f2f6dcb3
commit 54637e7ee1

View File

@ -11,10 +11,10 @@ if (-f "$HOME/.perl-homedir") then
eval `sed -ne 's|^[[:blank:]]*\([^#=]\{1,\}\)=\([^=]*\)|setenv \1 \2;|p' "$HOME/.perl-homedir"`
endif
alias perlll 'eval "`perl -Mlocal::lib`"'
alias perlll 'eval "`env SHELL=csh perl -Mlocal::lib`"'
# if system default
if ("x$PERL_HOMEDIR" == "x1") then
eval "`perl -Mlocal::lib`"
eval "`env SHELL=csh perl -Mlocal::lib`"
endif