From 8fda1ebdc14a959ac995aae6c1cfe6ee04dc3923 Mon Sep 17 00:00:00 2001 From: Siegfried-Angel Gevatter Pujals Date: Tue, 21 Sep 2010 21:25:33 +0200 Subject: [PATCH] Wrap any extra (user) arguments appended to the pbuilder command with quotation marks, when needed (LP: #398989). --- debian/changelog | 2 ++ pbuilder-dist | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 445805b..66e8dc3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,8 @@ ubuntu-dev-tools (0.103) UNRELEASED; urgency=low * pbuilder-dist: - Do not show a warning when "experimental" is used; there is no debootstrap file for it but it should just work anyway. + - Wrap any extra (user) arguments appended to the pbuilder command with + quotation marks, when needed (LP: #398989). * bash_completion/pbuilder-dist: - Enable auto-completion for "pbuilder-experimental". diff --git a/pbuilder-dist b/pbuilder-dist index 28d2067..b3e80eb 100755 --- a/pbuilder-dist +++ b/pbuilder-dist @@ -245,8 +245,22 @@ class pbuilder_dist: if remaining_arguments: arguments.extend(remaining_arguments) + def quote(argument): + """ quote(argument) -> string + + Try to guess any missing quotes around the arguments so that + their meaning doesn't get lost (see LP: #398989). + + """ + + if argument.startswith('--'): + if '=' in argument: + return '%s="%s"' % tuple(argument.split('=', 1)) + return argument + return '"%s"' % argument + return '%s /usr/sbin/%s %s' % (self.auth, self.builder, - ' '.join(arguments)) + ' '.join(map(quote, arguments))) def ask(question): """ ask(question) -> string