From 75a96e69ea019c32d5a6a56a86f258ea18585d72 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 9 May 2007 03:50:58 +0000 Subject: [PATCH] Handle case in update-alternatives when there's no existing alternative to configure. Closes: #260987, #353252, #367717, #392431 --- ChangeLog | 8 ++++++++ debian/changelog | 2 ++ scripts/update-alternatives.pl | 12 +++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 017a6cd3..36bebb2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-05-09 Guillem Jover + + * scripts/update-alternatives.pl (config_message): Handle the case + when @versions is empty. Return a negative value if there's nothing to + do, 0 on success. + (config_alternatives): Check for config_message exit value to decide + to return instead of @versions being empty. + 2007-05-09 Guillem Jover * scripts/dpkg-buildpackage.sh: Remove check for variable being empty, diff --git a/debian/changelog b/debian/changelog index 2a5815e9..47260ac4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ dpkg (1.14.2) UNRELEASED; urgency=low * Remove bashisms in dpkg-buildpackage. Closes: #422239 + * Handle case in update-alternatives when there's no existing alternative + to configure. Closes: #260987, #353252, #367717, #392431 -- Guillem Jover Tue, 08 May 2007 18:48:22 +0300 diff --git a/scripts/update-alternatives.pl b/scripts/update-alternatives.pl index 08f175ed..0fc26dea 100755 --- a/scripts/update-alternatives.pl +++ b/scripts/update-alternatives.pl @@ -611,11 +611,17 @@ if ($manual eq 'auto') { } sub config_message { + if ($#versions < 0) { + print "\n"; + printf _g("There is no program which provides %s.\n". + "Nothing to configure.\n"), $name; + return -1; + } if ($#versions == 0) { print "\n"; printf _g("There is only 1 program which provides %s\n". "(%s). Nothing to configure.\n"), $name, $versions[0]; - return; + return -1; } print STDOUT "\n"; printf(STDOUT _g("There are %s alternatives which provide \`%s'.\n\n". @@ -629,13 +635,13 @@ sub config_message { $i+1, $versions[$i]); } printf(STDOUT "\n"._g("Press enter to keep the default[*], or type selection number: ")); + return 0; } sub config_alternatives { my $preferred; do { - &config_message; - if ($#versions == 0) { return; } + return if config_message() < 0; $preferred=; chop($preferred); } until $preferred eq '' || $preferred>=1 && $preferred<=$#versions+1 && -- 2.39.5