instead of checking for defined-ness and then comparing with the empty string, we can just use 'length' which returns undef if its argument is undef

This commit is contained in:
Johannes Schauer Marin Rodrigues 2021-03-08 07:54:04 +01:00
parent 270fd09b43
commit d52eaa4814
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -1219,16 +1219,16 @@ sub run_hooks {
# If the hook script needs a writable TMPDIR, then it can always use /tmp # If the hook script needs a writable TMPDIR, then it can always use /tmp
# inside the chroot. This is also why we do not set a new MMDEBSTRAP_TMPDIR # inside the chroot. This is also why we do not set a new MMDEBSTRAP_TMPDIR
# environment variable. # environment variable.
if (defined $ENV{TMPDIR} && $ENV{TMPDIR} ne "") { if (length $ENV{TMPDIR}) {
push @env_opts, '--unset=TMPDIR'; push @env_opts, '--unset=TMPDIR';
} }
# The APT_CONFIG variable, if set, will confuse any manual calls to # The APT_CONFIG variable, if set, will confuse any manual calls to
# apt-get. If you want to use the same config used by mmdebstrap, the # apt-get. If you want to use the same config used by mmdebstrap, the
# original value is stored in MMDEBSTRAP_APT_CONFIG. # original value is stored in MMDEBSTRAP_APT_CONFIG.
if (defined $ENV{APT_CONFIG} && $ENV{APT_CONFIG} ne "") { if (length $ENV{APT_CONFIG}) {
push @env_opts, '--unset=APT_CONFIG'; push @env_opts, '--unset=APT_CONFIG';
} }
if (defined $ENV{APT_CONFIG} && $ENV{APT_CONFIG} ne "") { if (length $ENV{APT_CONFIG}) {
push @env_opts, "MMDEBSTRAP_APT_CONFIG=$ENV{APT_CONFIG}"; push @env_opts, "MMDEBSTRAP_APT_CONFIG=$ENV{APT_CONFIG}";
} }
# Storing the mode is important for hook scripts to potentially change # Storing the mode is important for hook scripts to potentially change
@ -1871,7 +1871,7 @@ sub run_setup() {
} }
# setting PATH for chroot, ldconfig, start-stop-daemon... # setting PATH for chroot, ldconfig, start-stop-daemon...
if (defined $ENV{PATH} && $ENV{PATH} ne "") { if (length $ENV{PATH}) {
## no critic (Variables::RequireLocalizedPunctuationVars) ## no critic (Variables::RequireLocalizedPunctuationVars)
$ENV{PATH} = "$ENV{PATH}:/usr/sbin:/usr/bin:/sbin:/bin"; $ENV{PATH} = "$ENV{PATH}:/usr/sbin:/usr/bin:/sbin:/bin";
} else { } else {