From 791e0d22f99b8d24d9e1156ff0609715ff23f98b Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Fri, 20 Aug 2021 12:25:27 -0400 Subject: [PATCH] Spiff up shebang-fixing snippet --- grpc.spec | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/grpc.spec b/grpc.spec index 78a36b7..d1534da 100644 --- a/grpc.spec +++ b/grpc.spec @@ -672,15 +672,10 @@ find . -type f -name .gitignore -print -delete echo '===== Fixing shebangs =====' 2>&1 # Find executables with /usr/bin/env shebangs in the examples, and fix them. -find examples -type f -perm /0111 | - while read -r fn - do - if head -n 1 "${fn}" | grep -E '^#!/usr/bin/env[[:blank:]]' - then - sed -r -i '1{s|^(#!/usr/bin/)env[[:blank:]]+([^[:blank:]]+)|\1\2|}' \ - "${fn}" - fi - done +find . -type f -perm /0111 -exec gawk \ + '/^#!\/usr\/bin\/env[[:blank:]]/ { print FILENAME }; { nextfile }' \ + '{}' '+' | + xargs -r sed -r -i '1{s|^(#!/usr/bin/)env[[:blank:]]+([^[:blank:]]+)|\1\2|}' \ echo '===== Fixing line endings =====' 2>&1 # Fix some CRNL line endings: