]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
gl/funclib.sh: func_quotefast_eval & tilde fix
authorPavel Raiskup <praiskup@redhat.com>
Sun, 1 Nov 2015 20:43:31 +0000 (21:43 +0100)
committerPavel Raiskup <praiskup@redhat.com>
Wed, 4 Nov 2015 05:47:52 +0000 (06:47 +0100)
Testsuite detected that printf built-in in Bash up to 4.2 was not
able to properly escape tilde.

* gl/build-aux/funclib.sh (func_quote_for_eval): If printf
supports -v option, test also whether we properly escape tilde.
With Bash <= 4.2, call func_quote_portable with ~* strings.
* bootstrap: Sync with funclib.sh.

bootstrap
gl/build-aux/funclib.sh

index 1d86ab023e3934e78155995fa6b1d75ef31c87fe..6d62fb6fc787984d40c8d52e8874358814092842 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -230,7 +230,7 @@ vc_ignore=
 
 # Source required external libraries:
 # Set a version string for this script.
-scriptversion=2015-10-12.13; # UTC
+scriptversion=2015-11-01.21; # UTC
 
 # General shell script boiler plate, and helper functions.
 # Written by Gary V. Vaughan, 2004
@@ -1337,10 +1337,27 @@ func_quote_portable ()
 # Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
 # but optimized for speed.  Result is stored in $func_quotefast_eval.
 if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
-  func_quotefast_eval ()
-  {
-    printf -v func_quotefast_eval_result %q "$1"
-  }
+  printf -v _GL_test_printf_tilde %q '~'
+  if test '\~' = "$_GL_test_printf_tilde"; then
+    func_quotefast_eval ()
+    {
+      printf -v func_quotefast_eval_result %q "$1"
+    }
+  else
+    # Broken older Bash implementations.  Make those faster too if possible.
+    func_quotefast_eval ()
+    {
+      case $1 in
+        '~'*)
+          func_quote_portable false "$1"
+          func_quotefast_eval_result=$func_quote_portable_result
+          ;;
+        *)
+          printf -v func_quotefast_eval_result %q "$1"
+          ;;
+      esac
+    }
+  fi
 else
   func_quotefast_eval ()
   {
index 2c22db179e591c007f3f0a1c7c60e0312686a439..d95ac2d78fa178f3905e0e9fec31413a23630bda 100644 (file)
@@ -1,5 +1,5 @@
 # Set a version string for this script.
-scriptversion=2015-10-12.13; # UTC
+scriptversion=2015-11-01.21; # UTC
 
 # General shell script boiler plate, and helper functions.
 # Written by Gary V. Vaughan, 2004
@@ -1106,10 +1106,27 @@ func_quote_portable ()
 # Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
 # but optimized for speed.  Result is stored in $func_quotefast_eval.
 if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
-  func_quotefast_eval ()
-  {
-    printf -v func_quotefast_eval_result %q "$1"
-  }
+  printf -v _GL_test_printf_tilde %q '~'
+  if test '\~' = "$_GL_test_printf_tilde"; then
+    func_quotefast_eval ()
+    {
+      printf -v func_quotefast_eval_result %q "$1"
+    }
+  else
+    # Broken older Bash implementations.  Make those faster too if possible.
+    func_quotefast_eval ()
+    {
+      case $1 in
+        '~'*)
+          func_quote_portable false "$1"
+          func_quotefast_eval_result=$func_quote_portable_result
+          ;;
+        *)
+          printf -v func_quotefast_eval_result %q "$1"
+          ;;
+      esac
+    }
+  fi
 else
   func_quotefast_eval ()
   {