[pacman-dev] [PATCH] makepkg: Don't interpret format specifiers in msg

Niklas Holm jadedcyborg at gmail.com
Fri Feb 23 10:42:29 UTC 2018


Message string containing for example windows paths would have
unexpected behaviour. For example the message "Check C:\foo\bar" would
be printed as "Check C:<newline>  oar".

Signed-off-by: Niklas Holm <jadedcyborg at gmail.com>
---
 scripts/libmakepkg/util/message.sh.in | 15 +++++----------
 scripts/library/output_format.sh      | 18 ++++++------------
 2 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/scripts/libmakepkg/util/message.sh.in b/scripts/libmakepkg/util/message.sh.in
index 33808de7..90799640 100644
--- a/scripts/libmakepkg/util/message.sh.in
+++ b/scripts/libmakepkg/util/message.sh.in
@@ -44,26 +44,21 @@ colorize() {
 }
 
 plain() {
-	local mesg=$1; shift
-	printf "${BOLD}    ${mesg}${ALL_OFF}\n" "$@" >&2
+	printf "${BOLD}    %s${ALL_OFF}\n" "$1" >&2
 }
 
 msg() {
-	local mesg=$1; shift
-	printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+	printf "${GREEN}==>${ALL_OFF}${BOLD} %s${ALL_OFF}\n" "$1" >&2
 }
 
 msg2() {
-	local mesg=$1; shift
-	printf "${BLUE}  ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+	printf "${BLUE}  ->${ALL_OFF}${BOLD} %s${ALL_OFF}\n" "$1" >&2
 }
 
 warning() {
-	local mesg=$1; shift
-	printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+	printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} %s${ALL_OFF}\n" "$1" >&2
 }
 
 error() {
-	local mesg=$1; shift
-	printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+	printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} %s${ALL_OFF}\n" "$1" >&2
 }
diff --git a/scripts/library/output_format.sh b/scripts/library/output_format.sh
index 9f02c00b..2049aab3 100644
--- a/scripts/library/output_format.sh
+++ b/scripts/library/output_format.sh
@@ -1,32 +1,26 @@
 plain() {
 	(( QUIET )) && return
-	local mesg=$1; shift
-	printf "${BOLD}    ${mesg}${ALL_OFF}\n" "$@" >&1
+	printf "${BOLD}    %s${ALL_OFF}\n" "$1" >&1
 }
 
 msg() {
 	(( QUIET )) && return
-	local mesg=$1; shift
-	printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1
+	printf "${GREEN}==>${ALL_OFF}${BOLD} %s${ALL_OFF}\n" "$1" >&1
 }
 
 msg2() {
 	(( QUIET )) && return
-	local mesg=$1; shift
-	printf "${BLUE}  ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1
+	printf "${BLUE}  ->${ALL_OFF}${BOLD} %s${ALL_OFF}\n" "$1" >&1
 }
 
 ask() {
-	local mesg=$1; shift
-	printf "${BLUE}::${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}" "$@" >&1
+	printf "${BLUE}::${ALL_OFF}${BOLD} %s${ALL_OFF}" "$1" >&1
 }
 
 warning() {
-	local mesg=$1; shift
-	printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+	printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} %s${ALL_OFF}\n" "$1" >&2
 }
 
 error() {
-	local mesg=$1; shift
-	printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
+	printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} %s${ALL_OFF}\n" "$1" >&2
 }
-- 
2.16.2


More information about the pacman-dev mailing list