Skip to content

Commit

Permalink
shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 9, 2024
1 parent c101b48 commit bd668f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion _glyphs/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ fontcustom compile "${dir}" \
"--output=${target}" \
--font-name=icons --templates=css --no-hash --force --autowidth --debug

cat "${target}/icons.css" | sed -E "s|\"./icons([^\"]+)\"|\"https://www.yegor256.com/css/icons\1?$(date +%s)\"|g" > "${target}/icons.css"
sed -E "s|\"./icons([^\"]+)\"|\"https://www.yegor256.com/css/icons\1?$(date +%s)\"|g" < "${target}/icons.css" > "${target}/icons.css"

2 changes: 1 addition & 1 deletion _rake/ping.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function ping_uri {
-H 'Accept-Encoding: gzip, deflate' \
-H 'Cache-Control: max-age=0' \
--retry 4 \
--write-out '%{http_code} %{url_effective}\n' $1
--write-out '%{http_code} %{url_effective}\n' "$1"
}
export -f ping_uri

Expand Down
23 changes: 11 additions & 12 deletions _rake/test_keywords.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,33 @@
mkdir -p _temp
rm -rf _temp/words.txt
echo -n "fetching all words... "
for f in $(find _site -name '*.html'); do
tidy -i -asxml $f 2>/dev/null | \
find _site -name '*.html' | while IFS= read -r f; do
tidy -i -asxml "${f}" 2>/dev/null | \
sed "s|>|>\n|g" | \
xmllint -html -xpath '(//article//p|//article//h2|//article//h3|//article//h4)/text()' - 2>/dev/null | \
sed "s/[^a-zA-Z]/ /g" | \
tr A-Z a-z | \
tr '[:upper:]' '[:lower:]' | \
sed 's/[ \t\n]/\n/g' | \
sed '/^[ \t]*$/d' >> _temp/words.txt
done
echo -e "done, $(wc -l _temp/words.txt | cut -f1 -d ' ') words found"

rm -rf _temp/good-words.txt
echo -n "removing stop words... "
cat _temp/words.txt | sort | uniq -c | sort -r | cut -c9- | \
while read k; do
grep -q $k _travis/stop-words.txt
if [ $? -ne 0 ]; then
echo $k >> _temp/good-words.txt
sort < _temp/words.txt | uniq -c | sort -r | cut -c9- | \
while read -r k; do
if ! grep -q "${k}" _travis/stop-words.txt; then
echo "${k}" >> _temp/good-words.txt
fi
done
echo "done, $(wc -l _temp/good-words.txt | cut -f1 -d ' ') good words left"

cat _temp/good-words.txt | head -200 > _temp/top-words.txt
head -200 < _temp/good-words.txt > _temp/top-words.txt

errors=0
while read k; do
while read -r k; do
echo -n "${k}: "
grep -q $k _temp/top-words.txt
grep -q "${k}" _temp/top-words.txt
if [ $? -eq 1 ]; then
echo "is absent!"
((errors++))
Expand All @@ -58,6 +57,6 @@ done < _travis/core-keywords.txt
if [ "$errors" -ne "0" ]; then
echo "there are ${errors} missed keywords, see above"
cat _temp/top-words.txt
exit -1
exit 1
fi

0 comments on commit bd668f4

Please sign in to comment.