summaryrefslogtreecommitdiff
path: root/cfg.mk
diff options
context:
space:
mode:
authorGary V. Vaughan <gary@gnu.org>2011-11-21 11:35:20 +0700
committerGary V. Vaughan <gary@gnu.org>2011-11-25 14:53:42 +0700
commit962aa919f51cdf8e2cee4fb2d1d9bafa34d50887 (patch)
tree24aa5e523abde226fc35c971d82116eb947da064 /cfg.mk
parent8fad6be03e8eca44e5e771cfbb907d3840a8e01e (diff)
downloadlibtool-962aa919f51cdf8e2cee4fb2d1d9bafa34d50887.tar.gz
syntax-check: fix violations and implement sc_prohibit_test_const_follows_var.
To safely use a non-literal first argument to `test', you must always prepend a literal non-`-' character, but often the second operand is a constant that doesn't begin with a `-' already, so always use `test a = "$b"' instead of noisy `test "X$b" = Xa'. * cfg.mk (sc_prohibit_test_const_follows_var): New syntax-check rule to ensure we don't reintroduce noisy test operands. * bootstrap, build-aux/extract-trace, build-aux/general.m4sh, build-aux/ltmain.m4sh, doc/libtool.texi, libtoolize.m4sh, m4/argz.m4, m4/libtool.m4, m4/ltdl.m4, tests/bindir.at, tests/defs.m4sh, tests/demo-relink.test, tests/demo/configure.ac, tests/depdemo-relink.test, tests/destdir.at, tests/duplicate_conv.at, tests/fail.at, tests/getopt-m4sh.at, tests/help.at, tests/libtoolize.at, tests/link-2.test, tests/link-order2.at, tests/lt_dlopenext.at, tests/mdemo/configure.ac, tests/mdemo2/configure.ac, tests/need_lib_prefix.at, tests/nocase.at, tests/pdemo/configure.ac, tests/pic_flag.at, tests/search-path.at, tests/shlibpath.at, tests/static.at, tests/sysroot.at, tests/tagtrace.test, tests/testsuite.at, tests/with-pic.at: Swap operands to avoid useless noise. Signed-off-by: Gary V. Vaughan <gary@gnu.org>
Diffstat (limited to 'cfg.mk')
-rw-r--r--cfg.mk12
1 files changed, 12 insertions, 0 deletions
diff --git a/cfg.mk b/cfg.mk
index 0338f6cb..918870ec 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -157,6 +157,18 @@ sc_prohibit_test_unary_operators:
halt="use \`if test -X' instead of \`if -X'" \
$(_sc_search_regexp)
+# Don't add noisy characters on the front of the left operand of a test
+# to prevent arguments being passed inadvertently (e.g. LHS is `-z'),
+# when the other operand is a constant -- just swap them, and remove the
+# spurious leading `x'.
+sc_prohibit_test_const_follows_var:
+ @var='[ ]+"[^$$"]*\$$[0-9A-Za-z_][^"]*"' \
+ op='[ ]+(!?=|-[lgn][et]|-eq)' \
+ const='[ ]+[^-$$][^$$; ]*' \
+ prohibit='test'$$var$$op$$const'[ ]*(&&|\|\||;|\\?$$)' \
+ halt='use `test a = "$$b"'\'' instead of `test "x$$b" = xa'\' \
+ $(_sc_search_regexp)
+
# Check for opening brace on next line in shell function definition.
exclude_file_name_regexp--sc_require_function_nl_brace = (^HACKING|\.[ch])$$
sc_require_function_nl_brace: