On Friday 09 of October 2015 17:16:03 Pavel Raiskup wrote: > > Here's a (lightly-tested) idea of what it would look like, where we'd > > have to audit every caller to deal with the result already including > > full quoting: > > > > if test yes = `(x=; printf -v x %q yes; echo $x) 2>/dev/null`; then > > func_quote() > > { > > printf -v func_quote_result %q "$1" > > } > > else > > func_quote() > > { > > portable version, except add: > > func_quote_result="\"$func_quote_result\"" > > } > > fi > > > > Note that with this variant, the portable version converts 'a *"b' into > > '"a *\"b"', while the bash version converts it into 'a\ \ \*\"b'. > > Thanks! I've done a simple testing too .. and it seems to be equivalent > to '$SED $sed_quote_subst' (in usecases like: string -> quote -> eval). > > Well -- I'm not 100% sure I want to hack this in and risk some issues. On > the other hand, I'm able to review the patches if somebody wanted to give > it a try (the small bash slowdown from v2.4.2 to v2.4.6 is not good > motivation for me). Hm, I was thinking thinking about this over the weekend and I wanted to do some testing before I would definitely reject that idea. But it sounds like the printf builtin helps lets say significantly to bash and does not hurt others. I changed the function names so the changes to libtool code should be pretty transparent (even though it is rather large change). I'm posting results of the performance test (on systemd package) and attaching 3 "planned to be pushed" patches. So testing '2.4.2' version (fast), git-version after applying 0001 and 0002 (patch-2) and including 0003 (patch-3). The dirname of test is in format 'PACKAGE-SHELL-LTVERSION'. Pavel ----- %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-bash-2.4.2) 0:28.50 56.84 41.42 0:28.38 56.72 41.41 0:28.26 56.44 41.68 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-bash-2.4.6.13-f729) 1:06.13 232.12 23.33 1:06.52 232.28 23.35 1:06.54 232.16 23.52 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-bash-2.4.6.14-7a09) 0:46.52 151.16 24.48 0:46.64 150.80 24.60 0:46.69 151.12 23.85 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-dash-2.4.2) 0:16.34 22.22 28.62 0:17.13 22.57 29.09 0:17.11 22.37 29.24 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-dash-2.4.6.13-f729) 0:23.38 58.80 21.32 0:23.16 58.81 21.16 0:23.21 58.67 21.15 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-dash-2.4.6.14-7a09) 0:21.36 51.20 21.62 0:21.23 50.59 21.76 0:21.25 50.70 21.55 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-ksh-2.4.2) 0:19.65 30.76 34.12 0:21.09 30.68 34.63 0:19.75 30.83 34.29 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-ksh-2.4.6.13-f729) 0:30.75 85.60 25.41 0:30.70 85.51 25.52 0:30.80 85.65 25.41 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-ksh-2.4.6.14-7a09) 0:30.78 84.25 26.14 0:30.63 83.65 26.17 0:30.62 83.85 26.02 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-zsh-2.4.2) 0:27.94 44.47 48.97 0:28.03 44.29 49.31 0:28.60 44.48 48.93 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-zsh-2.4.6.13-f729) 0:47.60 140.30 41.70 0:47.53 139.84 41.89 0:47.56 139.71 42.12 %E %U %S (/home/praiskup/rh/projects/systemd-perf/systemd-zsh-2.4.6.14-7a09) 0:46.21 131.88 41.72 0:46.62 131.31 42.25 0:46.44 131.35 42.03