Package: dh-exec
Version: 0.6
Severity: normal
Tags: patch
Dear Maintainer,
*** Please consider answering these questions, where appropriate ***
* What led up to the situation?
* What exactly did you do (or not do) that was effective (or
ineffective)?
* What was the outcome of this action?
* What outcome did you expect instead?
*** End of the template - remove these lines ***
When attempting to substitute an empty (but set) variable via
dh-exec-subst-env, dh-exec falls back upon ${placeholder} instead of
just honouring the empty environment variable.
An example of a usecase:
foo.install:
file${suffix} /install/path
suffix="" debian/foo.install
-- System Information:
Debian Release: wheezy/sid
APT prefers raring-updates
APT policy: (500, 'raring-updates'), (500, 'raring-security'), (500,
'raring'), (400, 'raring-proposed'), (100, 'raring-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.9.3-hyper1 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages dh-exec depends on:
ii debhelper 9.20120909ubuntu1
ii libc6 2.17-0ubuntu5
ii libpipeline1 1.2.2-2
ii perl 5.14.2-21
dh-exec recommends no packages.
dh-exec suggests no packages.
-- no debconf information
>From f7ad06a3e88d9b7e5a7f37932d726dc6cfcb25fc Mon Sep 17 00:00:00 2001
From: Chow Loong Jin <[email protected]>
Date: Sat, 8 Jun 2013 22:09:39 +0800
Subject: [PATCH] Fix dh-exec-subst-env handling of empty vars
When an environment variable is set to an empty variable or 0, dh-exec ignores
it and restores the ${foo} placeholder, but this shouldn't be the case.
This commit checks for the existence of the variable in %ENV instead of just
using || for falling back.
---
lib/dh-exec-subst-env | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/dh-exec-subst-env b/lib/dh-exec-subst-env
index 312490e..940c39e 100755
--- a/lib/dh-exec-subst-env
+++ b/lib/dh-exec-subst-env
@@ -4,4 +4,4 @@
## corresponding environment variable, or the original ${...} if the
## env. var does not exist.
$_ = "" if /^#/;
-s/(\$\{([^\}]+)\})/$ENV{$2} || $1/eg;
+s/(\$\{([^\}]+)\})/exists $ENV{$2} ? $ENV{$2} : $1/eg;
--
1.8.1.2