Skip to content

Commit 08b43e1

Browse files
authored
Extract filename to constant
1 parent 7137268 commit 08b43e1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bin/update_list_count.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ set -o nounset
66
set -o pipefail
77
[[ "${TRACE-0}" =~ ^1|t|y|true|yes$ ]] && set -o xtrace
88

9+
FILE="README.md"
10+
911
MARKER_NATIVE="<magic-marker-nbr-native>"
1012
MARKER_EXTENSIONS="<magic-marker-nbr-extensions>"
1113

@@ -17,7 +19,7 @@ SIGN_EXTENSIONS=:heavy_plus_sign:
1719

1820
count_occurences() {
1921
local sign="$1"
20-
c=$(grep --count "$sign" README.md)
22+
c=$(grep --count "$sign" "$FILE")
2123
echo $(($c-1)) # Listed in explanation - does not count!
2224
}
2325

@@ -27,8 +29,8 @@ update_count() {
2729
local search="$3"
2830

2931
img_tag=$(printf "$template" "$count")
30-
sed -i.bak -e "s|^.*${search}.*$|${img_tag}|" README.md
31-
test -e README.md.bak && rm README.md.bak
32+
sed -i.bak -e "s|^.*${search}.*$|${img_tag}|" "$FILE"
33+
test -e "${FILE}.bak" && rm "${FILE}.bak"
3234
}
3335

3436
count_native=$(count_occurences $SIGN_NATIVE)

0 commit comments

Comments
 (0)