diff options
authorXZS2016-03-23 20:32:24 +0100
committerXZS2016-03-23 20:32:24 +0100
commitd996f44389fceb8b2360ebcc62caf538c544e68b (patch)
parenta530ac072bd14ca8547ea0ac33b5e8abe3b2f1c1 (diff)
end grep trickery, it has been busted
Unbelievably, also traditional tools like grep are regularly updated still today. Version 2.24 forbid the combination of some features with the -z option. This was exactly what was exploited here to make grep ignore newlines so they would not interrupt JSON dissection. More information about the change can be found at the bottom of the respective release notes. [1] Fixing it costs an invocation of tr to remove the bothersome newlines. Because the files are read within "find -exec" where input redirection is not readily possible, cat has to be invoked to start the pipeline. The grep script got only a tiny bit simpler by adhering to the new restriction and leaving newlines to tr. Thanks to AUR users jmauss, Asher256 and vinadoros for pointing to the critical line. [1]:
1 files changed, 2 insertions, 1 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 37c8d936e4e..b5d9576b8dc 100644
@@ -75,7 +75,8 @@ depends[125]=gnome-shell
package_20_version() {
local compatibles=($(\
find -path ./pkg -type d -prune -o \
- -name metadata.json -exec grep -Pzo '(?s)(?<="shell-version": \[)[^\[\]]*(?=\])' '{}' \; | \
+ -name metadata.json -exec cat '{}' \; | \
+ tr -d '\n' | grep -Po '(?<="shell-version": \[)[^\[\]]*(?=\])' | \
tr '\n," ' '\n' | sed 's/3\.//g;/^$/d' | sort -n -t. -k 1,1))
local max="${compatibles[-1]}"