Просмотр исходного кода

dpkg-maintscript-helper: Decouple local declaration from command assignment

The assignment within an export/local/declare builtin masks the command
return value, which means that if we are running with «set -e» the
shell will not notice an error from the command.

Warned-by: shellcheck
Guillem Jover лет назад: 10
Родитель
Сommit
fbdbddc0a8
2 измененных файлов с 9 добавлено и 4 удалено
  1. 3 0
      debian/changelog
  2. 6 4
      scripts/dpkg-maintscript-helper.sh

+ 3 - 0
debian/changelog

@@ -57,6 +57,9 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
     dpkg-maintscript-helper, instead of using a variable pathname as a regex
     with grep, which is susceptible to metacharacters acting as part of the
     regex. Proposed by Carsten Hey <carsten@debian.org>.
+  * Decouple local keyword declaration from command assignment in
+    dpkg-maintscript-helper, which masks the command return value when
+    using «set -e».
   * Portability:
     - Move DPKG_ADMINDIR environment variable name out from update-alternatives
       code, to make life easier for non-dpkg-based systems.

+ 6 - 4
scripts/dpkg-maintscript-helper.sh

@@ -88,8 +88,9 @@ prepare_rm_conffile() {
 	[ -e "$CONFFILE" ] || return 0
 	ensure_package_owns_file "$PACKAGE" "$CONFFILE" || return 0
 
-	local md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
-	local old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
+	local md5sum old_md5sum
+	md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
+	old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
 		sed -n -e "\'^ $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
 	if [ "$md5sum" != "$old_md5sum" ]; then
 		mv -f "$CONFFILE" "$CONFFILE.dpkg-backup"
@@ -191,8 +192,9 @@ prepare_mv_conffile() {
 
 	ensure_package_owns_file "$PACKAGE" "$CONFFILE" || return 0
 
-	local md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
-	local old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
+	local md5sum old_md5sum
+	md5sum="$(md5sum "$CONFFILE" | sed -e 's/ .*//')"
+	old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$PACKAGE" | \
 		sed -n -e "\'^ $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
 	if [ "$md5sum" = "$old_md5sum" ]; then
 		mv -f "$CONFFILE" "$CONFFILE.dpkg-remove"