aboutsummaryrefslogtreecommitdiff
path: root/_tils/2020-12-15-awk-snippet-shellcheck-all-scripts-in-a-repository.md
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-12-15 14:16:03 -0300
committerEuAndreh <eu@euandre.org>2020-12-15 14:16:41 -0300
commit5f8d70d4ca4e6cd13ff8a928df8b4b82b0f7595d (patch)
tree09597c2fc0a90c573471494f432c002c750d72ba /_tils/2020-12-15-awk-snippet-shellcheck-all-scripts-in-a-repository.md
parentRemove templates/* (diff)
downloadeuandre.org-5f8d70d4ca4e6cd13ff8a928df8b4b82b0f7595d.tar.gz
euandre.org-5f8d70d4ca4e6cd13ff8a928df8b4b82b0f7595d.tar.xz
TIL on Awk: Add update section with POSIX Awk version
Diffstat (limited to '')
-rw-r--r--_tils/2020-12-15-awk-snippet-shellcheck-all-scripts-in-a-repository.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/_tils/2020-12-15-awk-snippet-shellcheck-all-scripts-in-a-repository.md b/_tils/2020-12-15-awk-snippet-shellcheck-all-scripts-in-a-repository.md
index 91ab22e..2b434b4 100644
--- a/_tils/2020-12-15-awk-snippet-shellcheck-all-scripts-in-a-repository.md
+++ b/_tils/2020-12-15-awk-snippet-shellcheck-all-scripts-in-a-repository.md
@@ -150,5 +150,21 @@ Also when reviewing the text of this article, I found that `{ nextfile }` is a
GNU Awk extension. It would be an improvement if `assert-shellcheck.sh` relied
on the POSIX subset of Awk for working correctly.
+## *Update*
+
+After publishing, I could remove `{ nextfile }` and even make the script
+simpler:
+
+```shell
+#!/usr/sh
+set -eu
+
+git ls-files -z | \
+ xargs -0 awk 'FNR==1 && /^#!\// { print FILENAME }' | \
+ xargs shellcheck
+```
+
+Now both the shell and Awk usage are POSIX compatible.
+
[awk-20min]: https://ferd.ca/awk-in-20-minutes.html
[shellcheck]: https://www.shellcheck.net/