aboutsummaryrefslogtreecommitdiff
path: root/scripts/meta
blob: f7a3f8418ee53447aae0085e3a91273027bb3c91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

tag_name=$1
filename=$2

output=$(grep -Poh "^\[meta\]:\s+<$tag_name>\s+\(\K(.+)(?=\)$)" $filename)

if [ "$tag_name" = "tags" ]; then
	echo $output |\
		sed "s/,\s*/\n/g" |\
		sed -z '$ s/\n$//' |\
		jq --raw-input --slurp 'split("\n")'
else
	if [ "$output" = "" ]; then
		echo "" | jq --raw-input
	else
		echo $output |\
			sed -z '$ s/\n$//' |\
			jq --raw-input
	fi
fi