From: Paul Eggert Date: Tue, 1 Nov 2011 20:15:14 +0000 (-0700) Subject: * MODULES.html.sh: Fix sed-script shell quoting and locale issues. X-Git-Tag: v0.1~1509 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=614046a2ff39f9973ce4a8a15aae4d541ae7be28;p=gnulib.git * MODULES.html.sh: Fix sed-script shell quoting and locale issues. (func_module): Replace foo=` ... sed -e COMPLICATED ... ` with bar=COMPLICATED; foo=` ... sed -e "$bar" ... ` when COMPLICATED contains (possibly-quoted) backslashes. This should avoid all-too-common shell bugs if COMPLICATED contains backslashes in the "wrong" places. Reported by David Evans in . When 'sed' uses character ranges like A-Z, invoke it in the C locale, because we want ASCII ranges. Is there some reason we don't use the C locale everywhere in this script? (func_module, top level): Avoid unwanted pathname expansion when $repo_url_prefix or $repo_url_suffix_repl contain shell metacharacters like '?' and '*'. --- diff --git a/ChangeLog b/ChangeLog index 8e52143f36..d5df470f05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2011-11-01 Paul Eggert + + * MODULES.html.sh: Fix sed-script shell quoting and locale issues. + (func_module): Replace foo=` ... sed -e COMPLICATED ... ` with + bar=COMPLICATED; foo=` ... sed -e "$bar" ... ` when COMPLICATED + contains (possibly-quoted) backslashes. This should avoid + all-too-common shell bugs if COMPLICATED contains backslashes in + the "wrong" places. Reported by David Evans in + . + When 'sed' uses character ranges like A-Z, invoke it in the C locale, + because we want ASCII ranges. Is there some reason we don't use + the C locale everywhere in this script? + (func_module, top level): Avoid unwanted pathname expansion when + $repo_url_prefix or $repo_url_suffix_repl contain shell + metacharacters like '?' and '*'. + 2011-11-01 Bruno Haible fchownat: Improve description. diff --git a/MODULES.html.sh b/MODULES.html.sh index ba85225871..34ca5cc3d7 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1512,19 +1512,26 @@ func_module () # parentheses (as per GNU standards, section "GNU Manuals"). # - Flag the remaining symbol() constructs as errors. # - Change 'xxx' to xxx. + sed_extract_element=' + '$sed_lt' + '$sed_gt' + '$sed_remove_trailing_empty_line' + s,^, , + s,$, , + s,\([^a-zA-Z_]\)'$posix_functions'() \(function\|macro\),\1\2 \3,g + s,\([^a-zA-Z_]\)'$posix_functions' \(function\|macro\),\1\2 \3,g + s,\([^a-zA-Z_]\)'$posix_functions'(),\1\2 what?? If you mean a function\, please say so.,g + s,\([^a-zA-Z_]\)'$posix2001_functions'() \(function\|macro\),\1\2 \3,g + s,\([^a-zA-Z_]\)'$posix2001_functions' \(function\|macro\),\1\2 \3,g + s,\([^a-zA-Z_]\)'$posix2001_functions'(),\1\2 what?? If you mean a function\, please say so.,g + s,\([^a-zA-Z_]\)\([a-zA-Z_][a-zA-Z0-9_]*\)() \(function\|macro\),\1\2 \3,g + s,\([^a-zA-Z_]\)\([a-zA-Z_][a-zA-Z0-9_]*\)(),\1\2 what?? If you mean a function\, please say so.,g + s, '"'"'\([a-zA-Z0-9_ -]*\)'"'"'\([^a-zA-Z0-9_]\), \1\2,g + s,^ ,, + s, $,, + ' element=`gnulib-tool --extract-description $1 \ - | sed -e "$sed_lt" -e "$sed_gt" -e "$sed_remove_trailing_empty_line" \ - -e 's,^, ,' -e 's,$, ,' \ - -e 's,\([^a-zA-Z_]\)'"${posix_functions}"'() \(function\|macro\),\1\2 \3,g' \ - -e 's,\([^a-zA-Z_]\)'"${posix_functions}"' \(function\|macro\),\1\2 \3,g' \ - -e 's,\([^a-zA-Z_]\)'"${posix_functions}"'(),\1\2 what?? If you mean a function\, please say so.,g' \ - -e 's,\([^a-zA-Z_]\)'"${posix2001_functions}"'() \(function\|macro\),\1\2 \3,g' \ - -e 's,\([^a-zA-Z_]\)'"${posix2001_functions}"' \(function\|macro\),\1\2 \3,g' \ - -e 's,\([^a-zA-Z_]\)'"${posix2001_functions}"'(),\1\2 what?? If you mean a function\, please say so.,g' \ - -e 's,\([^a-zA-Z_]\)\([a-zA-Z_][a-zA-Z0-9_]*\)() \(function\|macro\),\1\2 \3,g' \ - -e 's,\([^a-zA-Z_]\)\([a-zA-Z_][a-zA-Z0-9_]*\)(),\1\2 what?? If you mean a function\, please say so.,g' \ - -e 's, '"'"'\([a-zA-Z0-9_ -]*\)'"'"'\([^a-zA-Z0-9_]\), \1\2,g' \ - -e 's,^ ,,' -e 's, $,,'` + | LC_ALL=C sed -e "$sed_extract_element"` func_echo "$element" func_end TR @@ -1539,13 +1546,19 @@ func_module () includes=`gnulib-tool --extract-include-directive $1` files=`gnulib-tool --extract-filelist $1 \ | grep -v '^m4/gnulib-common\.m4$'` + sed_extract_element=' + '$sed_lt' + '$sed_gt' + '$sed_remove_trailing_empty_line' + s,^#include "\(.*\)"$,#include "\1", + s,^#include <'$posix_headers'\.h>$,#include \<\1.h\>, + s,,, + s,^#include <'$posix2001_headers'\.h>$,#include \<\1.h\>, + s/$/
/ + ' element=`echo "$includes" \ - | sed -e "$sed_lt" -e "$sed_gt" -e "$sed_remove_trailing_empty_line" \ - -e 's,^#include "\(.*\)"$,#include "\1",' \ - -e 's,^#include <'"${posix_headers}"'\.h>$,#include \<\1.h\>,' \ - -e 's,,,' \ - -e 's,^#include <'"${posix2001_headers}"'\.h>$,#include \<\1.h\>,' \ - -e 's/$/
/' | tr -d "$trnl" | sed -e 's/
$//'` + | LC_ALL=C sed -e "$sed_extract_element" | tr -d "$trnl" \ + | sed -e 's/
$//'` test -n "$element" || element='---' func_echo "$element" @@ -1554,21 +1567,28 @@ func_module () | sed -n -e "$sed_choose_unconditional_nonstandard_include" \ | sed -e "$sed_escape_dot" | tr -d "$trnl"` sed_choose_lib_files='s,^lib/\(.*\)$,\1,p' + sed_extract_include=' + \|^'"$includefile"'$|d + s,^\(.*\)$,\1, + s/$/
/ + ' element=`echo "$files" \ | sed -e '/^$/d' \ | sed -n -e "$sed_choose_lib_files" \ - | sed -e '\|^'"${includefile}"'$|d' \ - -e 's,^\(.*\)$,\1,' \ - -e 's/$/
/' | tr -d "$trnl" | sed -e 's/
$//'` + | sed -e "$sed_extract_include" \ + | tr -d "$trnl" | sed -e 's/
$//'` test -n "$element" || element='---' func_echo "$element" sed_choose_m4_files='s,^m4/\(.*\)$,\1,p' + sed_extract_repo_url=' + /^onceonly/d + s,^\(.*\)$,\1, + ' element=`(echo "$files" \ | sed -e "$sed_remove_trailing_empty_line" \ | sed -n -e "$sed_choose_m4_files" \ - | sed -e '/^onceonly/d' \ - -e 's,^\(.*\)$,\1,'; \ + | sed -e "$sed_extract_repo_url"; \ gnulib-tool --extract-autoconf-snippet $1 \ | sed -e "$sed_remove_trailing_empty_line") \ | sed -e 's/$/
/' | tr -d "$trnl" | sed -e 's/
$//'` @@ -3600,7 +3620,7 @@ if test -n "$missed_files"; then func_echo "$element" func_echo '
'
-  echo "$missed_files" | sed -e 's,^\(.*\)$,\1,'
+  echo "$missed_files" | sed -e 's,^\(.*\)$,\1,'
   echo '
' fi