diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2021-09-14 21:14:13 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2021-09-15 10:38:47 +0200 |
commit | ce139f9887e5f5403cf2ff367722ac12aa050fea (patch) | |
tree | 8d6737355c5375d789d495dae62e3e985bbfba2a | |
parent | 1867a92570347493d96a1169d38b4cca90ff2d12 (diff) | |
download | pw-ce139f9887e5f5403cf2ff367722ac12aa050fea.tar.gz |
pw-apply: Use awk for multi-line subject line extraction
Instead of using experimental `grep -P` which doesn't work in some
distros, do it with line-by-line AWK script which collects all line
beginning with the line that starts with "Subject: " and ending before
hitting the line starting with another "<keyword>: ". This works for
single-line and multi-line subjects.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rwxr-xr-x | pw-apply | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -183,7 +183,7 @@ if [ ! -z "$merge" ]; then author=$(echo "${BASH_REMATCH[1]}" | base64 -d) fi # Extract cover letter subject, potentially split into two lines - branch_name=$(grep -Pzo '(?<=^Subject: ).*?\n?.*?(?=\n\w+: )' cover.i | tr -d '\n' | cut -d']' -f2 | cut -c 2-) + branch_name=$(awk '/^\w+: / { subj=0 } /^Subject: / { subj = 1 } subj { print $0 }' cover.i | tr -d '\n' | cut -d']' -f2 | cut -c 2-) text=`grep -A300 'X-Mailing-List:' cover.i |tail --lines=+3|grep -B300 -E "^.*\([0-9]+\):$"|head --lines=-2` git commit --amend --signoff -F- <<EOF Merge branch '$branch_name' |