Module Name: src
Committed By: apb
Date: Mon Aug 4 21:56:30 UTC 2014
Modified Files:
src: build.sh
src/share/zoneinfo: tzdata2netbsd
src/usr.bin/locate/locate: updatedb.sh
src/usr.sbin/etcupdate: etcupdate
src/usr.sbin/postinstall: postinstall
Log Message:
Synchronise several shell_quote implementations, and:
* Elide some unnecessary pairs of quotation marks, to improve readability.
For example, shell_quote "''" is now \'\' instead of ''\'''\'''.
* Don't add quotes around words that contain only safe characters,
to improve readability.
* LC_COLLATE=C to prevent [a-zA-Z] from matching non-ASCII characters.
* Use ${SED} if defined.
To generate a diff of this commit:
cvs rdiff -u -r1.288 -r1.289 src/build.sh
cvs rdiff -u -r1.3 -r1.4 src/share/zoneinfo/tzdata2netbsd
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/locate/locate/updatedb.sh
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/etcupdate/etcupdate
cvs rdiff -u -r1.174 -r1.175 src/usr.sbin/postinstall/postinstall
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/build.sh
diff -u src/build.sh:1.288 src/build.sh:1.289
--- src/build.sh:1.288 Sun Aug 3 17:11:44 2014
+++ src/build.sh Mon Aug 4 21:56:30 2014
@@ -1,5 +1,5 @@
#! /usr/bin/env sh
-# $NetBSD: build.sh,v 1.288 2014/08/03 17:11:44 riz Exp $
+# $NetBSD: build.sh,v 1.289 2014/08/04 21:56:30 apb Exp $
#
# Copyright (c) 2001-2011 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -286,21 +286,43 @@ ERRORMESSAGE
# eval "set -- $quotedlist"
# or like this:
# eval "\$command $quotedlist \$filename"
+#
shell_quote()
-{
+{(
local result=''
- local arg
+ local arg qarg
+ LC_COLLATE=C ; export LC_COLLATE # so [a-zA-Z0-9] works in ASCII
for arg in "$@" ; do
- # Append a space if necessary
- result="${result}${result:+ }"
- # Convert each embedded ' to '\'',
- # then insert ' at the beginning of the first line,
- # and append ' at the end of the last line.
- result="${result}$(printf "%s\n" "$arg" | \
- sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/")"
+ case "${arg}" in
+ '')
+ qarg="''"
+ ;;
+ *[!-./a-zA-Z0-9]*)
+ # Convert each embedded ' to '\'',
+ # then insert ' at the beginning of the first line,
+ # and append ' at the end of the last line.
+ # Finally, elide unnecessary '' pairs at the
+ # beginning and end of the result and as part of
+ # '\'''\'' sequences that result from multiple
+ # adjacent quotes in he input.
+ qarg="$(printf "%s\n" "$arg" | \
+ ${SED:-sed} -e "s/'/'\\\\''/g" \
+ -e "1s/^/'/" -e "\$s/\$/'/" \
+ -e "1s/^''//" -e "\$s/''\$//" \
+ -e "s/'''/'/g"
+ )"
+ ;;
+ *)
+ # Arg is not the empty string, and does not contain
+ # any unsafe characters. Leave it unchanged for
+ # readability.
+ qarg="${arg}"
+ ;;
+ esac
+ result="${result}${result:+ }${qarg}"
done
printf "%s\n" "$result"
-}
+)}
statusmsg()
{
@@ -1774,7 +1796,7 @@ createmakewrapper()
eval cat <<EOF ${makewrapout}
#! ${HOST_SH}
# Set proper variables to allow easy "make" building of a NetBSD subtree.
-# Generated from: \$NetBSD: build.sh,v 1.288 2014/08/03 17:11:44 riz Exp $
+# Generated from: \$NetBSD: build.sh,v 1.289 2014/08/04 21:56:30 apb Exp $
# with these arguments: ${_args}
#
Index: src/share/zoneinfo/tzdata2netbsd
diff -u src/share/zoneinfo/tzdata2netbsd:1.3 src/share/zoneinfo/tzdata2netbsd:1.4
--- src/share/zoneinfo/tzdata2netbsd:1.3 Fri Jun 13 19:56:19 2014
+++ src/share/zoneinfo/tzdata2netbsd Mon Aug 4 21:56:30 2014
@@ -1,4 +1,4 @@
-# $NetBSD: tzdata2netbsd,v 1.3 2014/06/13 19:56:19 apb Exp $
+# $NetBSD: tzdata2netbsd,v 1.4 2014/08/04 21:56:30 apb Exp $
# For use by NetBSD developers when updating to new versions of tzdata.
#
@@ -75,29 +75,43 @@ DOIT()
# eval "set -- $quotedlist"
# or like this:
# eval "\$command $quotedlist \$filename"
+#
shell_quote()
-{
+{(
local result=''
local arg qarg
+ LC_COLLATE=C ; export LC_COLLATE # so [a-zA-Z0-9] works in ASCII
for arg in "$@" ; do
case "${arg}" in
- ''|*[!-./a-zA-Z0-9]*)
+ '')
+ qarg="''"
+ ;;
+ *[!-./a-zA-Z0-9]*)
# Convert each embedded ' to '\'',
# then insert ' at the beginning of the first line,
# and append ' at the end of the last line.
+ # Finally, elide unnecessary '' pairs at the
+ # beginning and end of the result and as part of
+ # '\'''\'' sequences that result from multiple
+ # adjacent quotes in he input.
qarg="$(printf "%s\n" "$arg" | \
- sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/")"
+ ${SED:-sed} -e "s/'/'\\\\''/g" \
+ -e "1s/^/'/" -e "\$s/\$/'/" \
+ -e "1s/^''//" -e "\$s/''\$//" \
+ -e "s/'''/'/g"
+ )"
;;
*)
# Arg is not the empty string, and does not contain
- # any unsafe characters.
+ # any unsafe characters. Leave it unchanged for
+ # readability.
qarg="${arg}"
;;
esac
result="${result}${result:+ }${qarg}"
done
printf "%s\n" "$result"
-}
+)}
findcvsroot()
{
Index: src/usr.bin/locate/locate/updatedb.sh
diff -u src/usr.bin/locate/locate/updatedb.sh:1.14 src/usr.bin/locate/locate/updatedb.sh:1.15
--- src/usr.bin/locate/locate/updatedb.sh:1.14 Wed Jul 13 07:58:35 2011
+++ src/usr.bin/locate/locate/updatedb.sh Mon Aug 4 21:56:30 2014
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: updatedb.sh,v 1.14 2011/07/13 07:58:35 apb Exp $
+# $NetBSD: updatedb.sh,v 1.15 2014/08/04 21:56:30 apb Exp $
#
# Copyright (c) 1989, 1993
# The Regents of the University of California. All rights reserved.
@@ -61,20 +61,41 @@ SRCHPATHS=
# eval "\$command $quotedlist \$filename"
#
shell_quote()
-{
+{(
local result=''
- local arg
+ local arg qarg
+ LC_COLLATE=C ; export LC_COLLATE # so [a-zA-Z0-9] works in ASCII
for arg in "$@" ; do
- # Append a space if necessary
- result="${result}${result:+ }"
- # Convert each embedded ' to '\'',
- # then insert ' at the beginning of the first line,
- # and append ' at the end of the last line.
- result="${result}$(printf "%s\n" "$arg" | \
- sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/")"
+ case "${arg}" in
+ '')
+ qarg="''"
+ ;;
+ *[!-./a-zA-Z0-9]*)
+ # Convert each embedded ' to '\'',
+ # then insert ' at the beginning of the first line,
+ # and append ' at the end of the last line.
+ # Finally, elide unnecessary '' pairs at the
+ # beginning and end of the result and as part of
+ # '\'''\'' sequences that result from multiple
+ # adjacent quotes in he input.
+ qarg="$(printf "%s\n" "$arg" | \
+ ${SED:-sed} -e "s/'/'\\\\''/g" \
+ -e "1s/^/'/" -e "\$s/\$/'/" \
+ -e "1s/^''//" -e "\$s/''\$//" \
+ -e "s/'''/'/g"
+ )"
+ ;;
+ *)
+ # Arg is not the empty string, and does not contain
+ # any unsafe characters. Leave it unchanged for
+ # readability.
+ qarg="${arg}"
+ ;;
+ esac
+ result="${result}${result:+ }${qarg}"
done
printf "%s\n" "$result"
-}
+)}
# read configuration file
if [ -f "$CONF" ]; then
Index: src/usr.sbin/etcupdate/etcupdate
diff -u src/usr.sbin/etcupdate/etcupdate:1.57 src/usr.sbin/etcupdate/etcupdate:1.58
--- src/usr.sbin/etcupdate/etcupdate:1.57 Mon Jun 16 22:12:30 2014
+++ src/usr.sbin/etcupdate/etcupdate Mon Aug 4 21:56:30 2014
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: etcupdate,v 1.57 2014/06/16 22:12:30 apb Exp $
+# $NetBSD: etcupdate,v 1.58 2014/08/04 21:56:30 apb Exp $
#
# Copyright (c) 2001-2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -138,21 +138,43 @@ yesno() {
# eval "set -- $quotedlist"
# or like this:
# eval "\$command $quotedlist \$filename"
+#
shell_quote()
-{
+{(
local result=''
- local arg
+ local arg qarg
+ LC_COLLATE=C ; export LC_COLLATE # so [a-zA-Z0-9] works in ASCII
for arg in "$@" ; do
- # Append a space if necessary
- result="${result}${result:+ }"
- # Convert each embedded ' to '\'',
- # then insert ' at the beginning of the first line,
- # and append ' at the end of the last line.
- result="${result}$(printf "%s\n" "$arg" | \
- sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/")"
+ case "${arg}" in
+ '')
+ qarg="''"
+ ;;
+ *[!-./a-zA-Z0-9]*)
+ # Convert each embedded ' to '\'',
+ # then insert ' at the beginning of the first line,
+ # and append ' at the end of the last line.
+ # Finally, elide unnecessary '' pairs at the
+ # beginning and end of the result and as part of
+ # '\'''\'' sequences that result from multiple
+ # adjacent quotes in he input.
+ qarg="$(printf "%s\n" "$arg" | \
+ ${SED:-sed} -e "s/'/'\\\\''/g" \
+ -e "1s/^/'/" -e "\$s/\$/'/" \
+ -e "1s/^''//" -e "\$s/''\$//" \
+ -e "s/'''/'/g"
+ )"
+ ;;
+ *)
+ # Arg is not the empty string, and does not contain
+ # any unsafe characters. Leave it unchanged for
+ # readability.
+ qarg="${arg}"
+ ;;
+ esac
+ result="${result}${result:+ }${qarg}"
done
printf "%s\n" "$result"
-}
+)}
# Convert arg $1 to a basic regular expression (as in sed)
# that will match the arg. This works by inserting backslashes
Index: src/usr.sbin/postinstall/postinstall
diff -u src/usr.sbin/postinstall/postinstall:1.174 src/usr.sbin/postinstall/postinstall:1.175
--- src/usr.sbin/postinstall/postinstall:1.174 Mon Jun 16 22:12:30 2014
+++ src/usr.sbin/postinstall/postinstall Mon Aug 4 21:56:30 2014
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: postinstall,v 1.174 2014/06/16 22:12:30 apb Exp $
+# $NetBSD: postinstall,v 1.175 2014/08/04 21:56:30 apb Exp $
#
# Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -112,21 +112,43 @@ mkdtemp()
# eval "set -- $quotedlist"
# or like this:
# eval "\$command $quotedlist \$filename"
+#
shell_quote()
-{
+{(
local result=''
- local arg
+ local arg qarg
+ LC_COLLATE=C ; export LC_COLLATE # so [a-zA-Z0-9] works in ASCII
for arg in "$@" ; do
- # Append a space if necessary
- result="${result}${result:+ }"
- # Convert each embedded ' to '\'',
- # then insert ' at the beginning of the first line,
- # and append ' at the end of the last line.
- result="${result}$(printf "%s\n" "$arg" | \
- ${SED} -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/")"
+ case "${arg}" in
+ '')
+ qarg="''"
+ ;;
+ *[!-./a-zA-Z0-9]*)
+ # Convert each embedded ' to '\'',
+ # then insert ' at the beginning of the first line,
+ # and append ' at the end of the last line.
+ # Finally, elide unnecessary '' pairs at the
+ # beginning and end of the result and as part of
+ # '\'''\'' sequences that result from multiple
+ # adjacent quotes in he input.
+ qarg="$(printf "%s\n" "$arg" | \
+ ${SED:-sed} -e "s/'/'\\\\''/g" \
+ -e "1s/^/'/" -e "\$s/\$/'/" \
+ -e "1s/^''//" -e "\$s/''\$//" \
+ -e "s/'''/'/g"
+ )"
+ ;;
+ *)
+ # Arg is not the empty string, and does not contain
+ # any unsafe characters. Leave it unchanged for
+ # readability.
+ qarg="${arg}"
+ ;;
+ esac
+ result="${result}${result:+ }${qarg}"
done
printf "%s\n" "$result"
-}
+)}
# Convert arg $1 to a basic regular expression (as in sed)
# that will match the arg. This works by inserting backslashes