aboutsummaryrefslogtreecommitdiff
path: root/scripts/meta
blob: e869d0b1ed5ae6a04bb62e4d69a2e33b55034c1c (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