[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/7] syntax-check: fix violations and implement sc_prohibit_bare_
From: |
Gary V. Vaughan |
Subject: |
[PATCH 4/7] syntax-check: fix violations and implement sc_prohibit_bare_basename. |
Date: |
Mon, 21 Nov 2011 21:47:28 +0700 |
* cfg.mk (sc_prohibit_bare_basename, sc_prohibit_basename_with_sed):
Make sure not to go back to using occasional `|$basename' or
`|$dirname' syntax.
* build-aux/general.m4sh, build-aux/git-hooks/commit-msg,
build-aux/ltmain.m4sh, build-aux/options-parser,
tests/fcdemo-conf.test, tests/fcdemo-shared.test,
tests/fcdemo-static.test, tests/libtoolize.at: Fix violations.
Signed-off-by: Gary V. Vaughan <address@hidden>
---
build-aux/general.m4sh | 12 ++++++------
build-aux/git-hooks/commit-msg | 4 ++--
build-aux/ltmain.m4sh | 2 +-
build-aux/options-parser | 6 +++---
cfg.mk | 11 +++++++++++
tests/fcdemo-conf.test | 2 +-
tests/fcdemo-shared.test | 2 +-
tests/fcdemo-static.test | 2 +-
tests/libtoolize.at | 4 ++--
9 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/build-aux/general.m4sh b/build-aux/general.m4sh
index 1f44535..790f4e0 100644
--- a/build-aux/general.m4sh
+++ b/build-aux/general.m4sh
@@ -70,15 +70,15 @@ lt_nl='
'
IFS=" $lt_nl"
-dirname='s,/[^/]*$,,'
-basename='s,^.*/,,'
+dirname='s|/[^/]*$||'
+basename='s|^.*/||'
# func_dirname file append nondir_replacement
# Compute the dirname of FILE. If nonempty, add APPEND to the result,
# otherwise set result to NONDIR_REPLACEMENT.
func_dirname ()
{
- func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
+ func_dirname_result=`$ECHO "${1}" |$SED "$dirname"`
if test "X$func_dirname_result" = "X${1}"; then
func_dirname_result=${3}
else
@@ -90,7 +90,7 @@ func_dirname ()
# func_basename file
func_basename ()
{
- func_basename_result=`$ECHO "${1}" | $SED "$basename"`
+ func_basename_result=`$ECHO "${1}" |$SED "$basename"`
} # func_basename may be replaced by extended shell implementation
@@ -109,13 +109,13 @@ func_basename ()
func_dirname_and_basename ()
{
# Extract subdirectory from the argument.
- func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
+ func_dirname_result=`$ECHO "${1}" |$SED "$dirname"`
if test "X$func_dirname_result" = "X${1}"; then
func_dirname_result=${3}
else
func_dirname_result=$func_dirname_result${2}
fi
- func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
+ func_basename_result=`$ECHO "${1}" |$SED "$basename"`
} # func_dirname_and_basename may be replaced by extended shell implementation
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index f2e6108..bbd7751 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -6,13 +6,13 @@
: ${SED="sed"}
test set = ${ECHO+'set'} = set || ECHO='printf %s\n'
-basename="$SED -e "'s|^.*/||'
+basename='s|^.*/||'
nl='
'
progpath=$0
-progname=`$ECHO "$progpath" |$basename`
+progname=`$ECHO "$progpath" |$SED "$basename"`
log_file=$1
export log_file
diff --git a/build-aux/ltmain.m4sh b/build-aux/ltmain.m4sh
index 02ff034..b367ddd 100644
--- a/build-aux/ltmain.m4sh
+++ b/build-aux/ltmain.m4sh
@@ -3042,7 +3042,7 @@ func_extract_archives ()
$RM
"unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
done # $darwin_arches
## Okay now we've a bunch of thin objects, gotta fatten them up :)
- darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name
\*.lo -print | $SED -e "$basename" | sort -u`
+ darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name
\*.lo -print | $SED $basename | sort -u`
darwin_file=
darwin_files=
for darwin_file in $darwin_filelist; do
diff --git a/build-aux/options-parser b/build-aux/options-parser
index 4777d76..566ae43 100644
--- a/build-aux/options-parser
+++ b/build-aux/options-parser
@@ -167,8 +167,8 @@ EXIT_SKIP=77 # $? = 77 is used to indicate a skipped
test to automake.
debug_cmd=${debug_cmd-":"}
exit_cmd=:
-dirname="$SED -e "'s|/[^/]*$||'
-basename="$SED -e "'s|^.*/||'
+dirname='s|/[^/]*$||'
+basename='s|^.*/||'
nl='
'
@@ -181,7 +181,7 @@ nl='
progpath=$0
# The name of this program.
-progname=`echo "$progpath" |$basename`
+progname=`echo "$progpath" |$SED "$basename"`
## ------------------------- ##
diff --git a/cfg.mk b/cfg.mk
index 3d2e2a6..8a44419 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -75,6 +75,17 @@ sc_prohibit_Xsed_without_X:
else :; \
fi || :
+# Use a consistent dirname and basename idiom.
+sc_prohibit_bare_basename:
+ @prohibit='\|[ ]*\$$(base|dir)name' \
+ halt='use `|$$SED "$$basename"'\'' instead of `|$$basename'\' \
+ $(_sc_search_regexp)
+
+sc_prohibit_basename_with_dollar_sed:
+ @prohibit='(base|dir)name="?(\$$SED|sed)[ "]' \
+ halt='use `basename='\''s|^.*/||'\'' instead of `basename="$$SED...'
\
+ $(_sc_search_regexp)
+
# Check for using `[' instead of `test'.
exclude_file_name_regexp--sc_prohibit_bracket_as_test = ^cfg.mk$$
sc_prohibit_bracket_as_test:
diff --git a/tests/fcdemo-conf.test b/tests/fcdemo-conf.test
index b7e08a6..028b53e 100755
--- a/tests/fcdemo-conf.test
+++ b/tests/fcdemo-conf.test
@@ -31,7 +31,7 @@ func_make_distclean
# We do not want to fail if all we got was a Fortran 77 compiler.
func_configure_nofail
if test "$conf_status" -eq "$EXIT_FAILURE"; then
- case `echo $FC | $SED $basename` in
+ case `echo $FC | $SED "$basename"` in
g77* | f77* | xlf | xlf[_-]* | frt* | pgf77* | cf77* | fort77* | fl32* |
af77*)
func_skip "The FC fortran tests do not work with Fortran 77 compilers"
;;
*) exit $EXIT_FAILURE
diff --git a/tests/fcdemo-shared.test b/tests/fcdemo-shared.test
index f20cb5d..76fb694 100755
--- a/tests/fcdemo-shared.test
+++ b/tests/fcdemo-shared.test
@@ -31,7 +31,7 @@ func_make_distclean
# We do not want to fail if all we got was a Fortran 77 compiler.
func_configure_nofail "--disable-static"
if test "$conf_status" -eq "$EXIT_FAILURE"; then
- case `echo $FC | $SED $basename` in
+ case `echo $FC | $SED "$basename"` in
g77* | f77* | xlf | xlf[_-]* | frt* | pgf77* | cf77* | fort77* | fl32* |
af77*)
func_skip "The FC fortran tests do not work with Fortran 77 compilers"
;;
*) exit $EXIT_FAILURE
diff --git a/tests/fcdemo-static.test b/tests/fcdemo-static.test
index 0f8dede..2e27020 100755
--- a/tests/fcdemo-static.test
+++ b/tests/fcdemo-static.test
@@ -31,7 +31,7 @@ func_make_distclean
# We do not want to fail if all we got was a Fortran 77 compiler.
func_configure_nofail "--disable-shared"
if test "$conf_status" -eq "$EXIT_FAILURE"; then
- case `echo $FC | $SED $basename` in
+ case `echo $FC | $SED "$basename"` in
g77* | f77* | xlf | xlf[_-]* | frt* | pgf77* | cf77* | fort77* | fl32* |
af77*)
func_skip "The FC fortran tests do not work with Fortran 77 compilers"
;;
*) exit $EXIT_FAILURE
diff --git a/tests/libtoolize.at b/tests/libtoolize.at
index e112acf..9c97fdb 100644
--- a/tests/libtoolize.at
+++ b/tests/libtoolize.at
@@ -696,7 +696,7 @@ LT_AT_ACLOCAL([-I $abs_top_srcdir/m4])
: ${GREP="grep"}
: ${SED="sed"}
-basename="$SED -e s,^.*/,,"
+basename='s,^.*/,,'
# func_grep expression filename
# Check whether EXPRESSION matches any line of FILENAME, without output.
@@ -724,7 +724,7 @@ func_serial ()
my_serial=
if test -z "$my_macro_regex" ||
test "$my_filename" = aclocal.m4 ||
- test "$my_macro_regex" = `echo "$my_filename" | $basename` ||
+ test "$my_macro_regex" = `echo "$my_filename" | $SED "$basename"` ||
func_grep '^AC_DEFUN(\@<:@'"$my_macro_regex" "$my_filename"
then
my_serial=`$SED -e "$my_sed_serial" "$my_filename"`
--
1.7.7.4
Cheers,
--
Gary V. Vaughan (gary AT gnu DOT org)