Fix setting undefined variable in CSH

This commit is contained in:
Petr Písař 2013-11-21 13:38:40 +01:00
parent 8b4ae68d2d
commit 659dfb8414
3 changed files with 58 additions and 3 deletions

View File

@ -0,0 +1,48 @@
From 53297b1441539efdc44fc9c8f4f19fb6ba8290c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 21 Nov 2013 12:03:32 +0100
Subject: [PATCH] Fix setting undefined variable in CSH
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
<https://rt.cpan.org/Public/Bug/Display.html?id=85667>
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
lib/local/lib.pm | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/local/lib.pm b/lib/local/lib.pm
index 289e13b..d4f8e2a 100644
--- a/lib/local/lib.pm
+++ b/lib/local/lib.pm
@@ -343,7 +343,24 @@ sub build_bourne_env_declaration {
sub build_csh_env_declaration {
my $class = shift;
my($name, $value) = @_;
- return defined($value) ? qq{setenv ${name} "${value}";\n} : qq{unsetenv ${name};\n};
+ if (defined($value)) {
+ if ($value =~ /(.*)(\A|\Q$Config{path_sep}\E)(\$)(.+?)(\z|\Q$Config{path_sep}\E)(.*)/) {
+ # If a variable reference exists in the value, we have to delimit it and
+ # dereference it only if it is defined.
+ return
+ qq{test 1 == \$\{?$4\} && } .
+ qq{setenv ${name} "${1}${2}${3}\{${4}\}${5}${6}"} .
+ qq{ || } .
+ qq{setenv ${name} "${1}} .
+ (($2 ne '' and $5 ne '') ? qq{${2}} : '') .
+ qq{${6}"} .
+ qq{;\n};
+ } else {
+ return qq{setenv ${name} "${value}";\n};
+ }
+ } else {
+ return qq{unsetenv ${name};\n};
+ }
}
sub build_win32_env_declaration {
--
1.8.3.1

View File

@ -11,10 +11,10 @@ if (-f "$HOME/.perl-homedir") then
source "$HOME/.perl-homedir"
endif
alias perlll 'eval `perl -Mlocal::lib`'
alias perlll 'eval "`perl -Mlocal::lib`"'
# if system default
if ("x$PERL_HOMEDIR" == "x1") then
eval `perl -Mlocal::lib`
eval "`perl -Mlocal::lib`"
endif

View File

@ -1,6 +1,6 @@
Name: perl-local-lib
Version: 1.008010
Release: 3%{?dist}
Release: 4%{?dist}
# lib/local/lib.pm -> GPL+ or Artistic
License: GPL+ or Artistic
Group: Development/Libraries
@ -8,6 +8,9 @@ Summary: Create and use a local lib/ for perl modules
Source: http://search.cpan.org/CPAN/authors/id/E/ET/ETHER/local-lib-%{version}.tar.gz
# Allow evaluation in CSH, RHBZ #849609, CPAN RT #60072
Patch0: local-lib-1.008009-Append-semicolon-to-setenv.patch
# Fix setting variables in CSH, RHBZ# 1033018, CPAN RT #85667,
# upstream is going the refactor the whole code, patch not sent to upstream
Patch1: local-lib-1.008010-Fix-setting-undefined-variable-in-CSH.patch
Url: http://search.cpan.org/dist/local-lib
Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
BuildArch: noarch
@ -65,6 +68,7 @@ install this package.
%prep
%setup -q -n local-lib-%{version}
%patch0 -p1
%patch1 -p1
rm -rf inc
%build
@ -91,6 +95,9 @@ make test
%{_sysconfdir}/profile.d/*
%changelog
* Thu Nov 21 2013 Petr Pisar <ppisar@redhat.com> - 1.008010-4
- Fix setting undefined variable in CSH (bug #1033018)
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.008010-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild