diff options
author | Jim Meyering <meyering@redhat.com> | 2011-11-12 16:08:56 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-11-12 18:38:46 +0100 |
commit | af8be8854b7719aea3c194a2dfbfce6c37d646f6 (patch) | |
tree | 475dd332fad562999a1140855d08e1e2b9fa0991 /tests/Makefile.am | |
parent | fc5be7ad57aec36d659878e4789ece0667397220 (diff) | |
download | grep-af8be8854b7719aea3c194a2dfbfce6c37d646f6.tar.gz |
tests: make our "export" replacement efficient with modern shells
* tests/Makefile.am (TESTS_ENVIRONMENT): Use a trivial and efficient
implementation with a shell that supports "export var=val".
Use the sed-invoking replacement only when necessary.
Improved by Stefano Lattarini.
Diffstat (limited to 'tests/Makefile.am')
-rw-r--r-- | tests/Makefile.am | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 50b57262..03ea23be 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -106,17 +106,21 @@ TESTS_ENVIRONMENT = \ tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \ TMPDIR=$$tmp__; export TMPDIR; \ \ - export_with_values () \ - { \ - sed_extract_var='s/=.*//'; \ - sed_quote_value="s/'/'\\\\''/g;s/=\\(.*\\)/='\\1'/";\ - for arg in "$$@"; do \ - var=`echo "$$arg" | sed "$$sed_extract_var"`; \ - arg=`echo "$$arg" | sed "$$sed_quote_value"`; \ - eval "$$arg"; \ - export "$$var"; \ - done; \ - }; \ + if test -n "$BASH_VERSION" || (eval "export v=x") 2>/dev/null; then \ + export_with_values () { export "$$@"; }; \ + else \ + export_with_values () \ + { \ + sed_extract_var='s/=.*//'; \ + sed_quote_value="s/'/'\\\\''/g;s/=\\(.*\\)/='\\1'/";\ + for arg in "$$@"; do \ + var=`echo "$$arg" | sed "$$sed_extract_var"`; \ + arg=`echo "$$arg" | sed "$$sed_quote_value"`; \ + eval "$$arg"; \ + export "$$var"; \ + done; \ + }; \ + fi; \ \ export_with_values \ VERSION='$(VERSION)' \ |