Mon Jul 12 19:03:20 2021 UTC ()
Revert 1.4, that just trades one problem for a different one
(splitting the message on % instead of white space, which affects
less messages, but makes a bigger mess of them when it happens).

The real problem is that the expansion of the message was unquoted,
which allowed the field splitting to happen at all (which was mitigated
by the way printf rescans its format string for each arg when there are
more args than conversions in the format) otherwise it would have been
a much bigger mess (both times).

Just add quotes where quotes are needed, no more splitting, all good.


(kre)
diff -r1.4 -r1.5 src/usr.sbin/sysinst/msg_xlat.sh

cvs diff -r1.4 -r1.5 src/usr.sbin/sysinst/msg_xlat.sh (expand / switch to unified diff)

--- src/usr.sbin/sysinst/msg_xlat.sh 2021/07/11 10:51:46 1.4
+++ src/usr.sbin/sysinst/msg_xlat.sh 2021/07/12 19:03:20 1.5
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! /bin/sh 1#! /bin/sh
2# $NetBSD: msg_xlat.sh,v 1.4 2021/07/11 10:51:46 cjep Exp $ 2# $NetBSD: msg_xlat.sh,v 1.5 2021/07/12 19:03:20 kre Exp $
3 3
4#- 4#-
5# Copyright (c) 2003 The NetBSD Foundation, Inc. 5# Copyright (c) 2003 The NetBSD Foundation, Inc.
6# All rights reserved. 6# All rights reserved.
7# 7#
8# This code is derived from software contributed to The NetBSD Foundation 8# This code is derived from software contributed to The NetBSD Foundation
9# by David Laight. 9# by David Laight.
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
@@ -164,27 +164,27 @@ do @@ -164,27 +164,27 @@ do
164 # For our purposes, empty messages are the same as words without % 164 # For our purposes, empty messages are the same as words without %
165 if [ $# -eq 0 ]; then set -- x; fi 165 if [ $# -eq 0 ]; then set -- x; fi
166  166
167 if $count_fmtargs; then 167 if $count_fmtargs; then
168 echo $number $# 168 echo $number $#
169 continue 169 continue
170 fi 170 fi
171 eval count=\${count_$number:-unknown} 171 eval count=\${count_$number:-unknown}
172 if [ "$count" -ne $# ]; then 172 if [ "$count" -ne $# ]; then
173 error "Wrong number of format specifiers in \"$sv_name\", got $#, expected $count" 173 error "Wrong number of format specifiers in \"$sv_name\", got $#, expected $count"
174 $IGNORE_MISSING_TRANSLATIONS || rval=1 174 $IGNORE_MISSING_TRANSLATIONS || rval=1
175 fi 175 fi
176done 176done
177IFS=% 177unset IFS
178 178
179if $count_fmtargs; then exit $rval; fi 179if $count_fmtargs; then exit $rval; fi
180 180
181# Output the total number of messages and the offset of each in the file. 181# Output the total number of messages and the offset of each in the file.
182# Use ascii numbers because generating target-ordered binary numbers 182# Use ascii numbers because generating target-ordered binary numbers
183# is just a smidgen tricky in the shell. 183# is just a smidgen tricky in the shell.
184 184
185offset=$(( 8 + $last_msg_number * 8 + 8 )) 185offset=$(( 8 + $last_msg_number * 8 + 8 ))
186printf 'MSGTXTS\0%-7d\0' $last_msg_number 186printf 'MSGTXTS\0%-7d\0' $last_msg_number
187 187
188msgnum=0 188msgnum=0
189while 189while
190 msgnum=$(( $msgnum + 1 )) 190 msgnum=$(( $msgnum + 1 ))
@@ -200,17 +200,17 @@ do @@ -200,17 +200,17 @@ do
200 printf '%-7d\0' $offset 200 printf '%-7d\0' $offset
201 offset=$(( $offset + ${#msg} + 1 )) 201 offset=$(( $offset + ${#msg} + 1 ))
202done 202done
203 203
204# Finally output and null terminate the messages. 204# Finally output and null terminate the messages.
205 205
206msgnum=0 206msgnum=0
207while 207while
208 msgnum=$(( $msgnum + 1 )) 208 msgnum=$(( $msgnum + 1 ))
209 [ "$msgnum" -le "$last_msg_number" ] 209 [ "$msgnum" -le "$last_msg_number" ]
210do 210do
211 eval msg=\${MSGTEXT_$msgnum} 211 eval msg=\${MSGTEXT_$msgnum}
212 if [ -z "$msg" ]; then continue; fi 212 if [ -z "$msg" ]; then continue; fi
213 printf '%s\0' $msg 213 printf '%s\0' "$msg"
214done 214done
215 215
216exit $rval 216exit $rval