aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-09-06 11:03:36 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-09-06 11:38:38 +0200
commit62df7214a1b6602bec3e355a0729de2968db6504 (patch)
tree0bd9e4eb965e40a3c9582371b0b45f9671b0320a /src
parentea5ff5547b365964ff2c0215caa3a2a020b6d7ed (diff)
add support for .sh files
Diffstat (limited to 'src')
-rwxr-xr-xsrc/extract-generic.sh17
-rwxr-xr-xsrc/extract-sh.sh8
-rwxr-xr-xsrc/extract.sh1
3 files changed, 24 insertions, 2 deletions
diff --git a/src/extract-generic.sh b/src/extract-generic.sh
index 0c84ec1..cadbb30 100755
--- a/src/extract-generic.sh
+++ b/src/extract-generic.sh
@@ -33,8 +33,21 @@ tree-grepper \
text=$(echo "$item" |
jq .match.text -r |
sed 's/^'"$LINE_COMMENT_START"' *TODO *//' |
- sed 's/^'"$BLOCK_COMMENT_START"' *TODO *//' |
- sed 's/ *'"$BLOCK_COMMENT_END"'$//')
+ {
+ if test -z "${BLOCK_COMMENT_START-}"; then
+ cat
+ else
+ sed 's/^'"$BLOCK_COMMENT_START"' *TODO *//'
+ fi
+ } |
+ {
+ if test -z "${BLOCK_COMMENT_END-}"; then
+ cat
+ else
+ sed 's/ *'"$BLOCK_COMMENT_END"'$//'
+ fi
+ }
+ )
echo "$item" | jq '. + {"text": $text, "last_commit": $last_commit}' \
--arg text "$text" \
diff --git a/src/extract-sh.sh b/src/extract-sh.sh
new file mode 100755
index 0000000..c31df74
--- /dev/null
+++ b/src/extract-sh.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+set -efu
+
+TREE_GREPPER_LANGUAGE=sh \
+TREE_GREPPER_QUERY='((comment)+)' \
+LINE_COMMENT_START='#' \
+"$(dirname "$0")"/extract-generic.sh "$@"
diff --git a/src/extract.sh b/src/extract.sh
index ce5c4d0..07eac37 100755
--- a/src/extract.sh
+++ b/src/extract.sh
@@ -14,6 +14,7 @@ find "$input_dir" -type f | grep -Pv '/\.|~$' |
case $input_file in
*.elm) ext="elm" ;;
*.nix) ext="nix" ;;
+ *.sh) ext="sh" ;;
*) ;;
esac