Module Name:    src
Committed By:   tls
Date:           Sun Aug 10 06:58:21 UTC 2014

Modified Files:
        src/usr.bin/locate/locate [tls-earlyentropy]: updatedb.sh

Log Message:
Rebase.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.18.1 src/usr.bin/locate/locate/updatedb.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

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.14.18.1
--- src/usr.bin/locate/locate/updatedb.sh:1.14	Wed Jul 13 07:58:35 2011
+++ src/usr.bin/locate/locate/updatedb.sh	Sun Aug 10 06:58:21 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.14.18.1 2014/08/10 06:58:21 tls 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

Reply via email to