aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-12-26 09:50:47 -0300
committerEuAndreh <eu@euandre.org>2020-12-26 09:50:57 -0300
commit77f78bb8562a0178a1434261cf5ab6ea8849fd13 (patch)
treed3a27ffbfcf4265a077b8d81b608d1a33e8090f0 /scripts
parentRemove generated media extensions (.ogg, .torrent) from gitignore (diff)
downloadeuandre.org-77f78bb8562a0178a1434261cf5ab6ea8849fd13.tar.gz
euandre.org-77f78bb8562a0178a1434261cf5ab6ea8849fd13.tar.xz
Use /bin/sh over Bash everywhere, remove patchShebangs from default.nix
Diffstat (limited to '')
-rwxr-xr-xscripts/apply-translations.sh7
-rwxr-xr-xscripts/assert-spelling.sh19
-rwxr-xr-xscripts/extract-translations.sh11
3 files changed, 15 insertions, 22 deletions
diff --git a/scripts/apply-translations.sh b/scripts/apply-translations.sh
index 291de76..1148b60 100755
--- a/scripts/apply-translations.sh
+++ b/scripts/apply-translations.sh
@@ -1,11 +1,8 @@
-#!/usr/bin/env bash
-set -Eeuo pipefail
-cd "$(dirname "${BASH_SOURCE[0]}")"
-cd ../
+#!/bin/sh -eu
for f in $(git ls-files | grep -E '.(md|slides)$' | grep -v '^vendor/reveal.js$'); do
l="$(grep '^lang: ..$' "$f" | awk '{print $2}')"
- if [[ "$l" != 'en' ]]; then
+ if [ "$l" != 'en' ]; then
ref="$(grep '^ref: ' "$f" | awk '{print $2}')"
# shellcheck disable=2046
FROM=$(find $(find . -name '*.md' -exec grep -l "^ref: $ref$" {} \;) -exec grep -l '^lang: en$' {} \;)
diff --git a/scripts/assert-spelling.sh b/scripts/assert-spelling.sh
index 615fddc..f4ab58e 100755
--- a/scripts/assert-spelling.sh
+++ b/scripts/assert-spelling.sh
@@ -1,12 +1,9 @@
-#!/usr/bin/env bash
-set -Eeuo pipefail
-cd "$(dirname "${BASH_SOURCE[0]}")"
-cd ../
+#!/bin/sh -eu
export LANG=C.UTF-8
for DICT in scripts/spelling/*.txt; do
- diff <(sort "$DICT") "$DICT" || {
+ sort "$DICT" | diff - "$DICT" || {
echo "The $DICT dictionary is unsorted. To fix it, run:" >&2
echo " LANG=C.UTF-8 sort $DICT | sponge $DICT" >&2
exit 1
@@ -14,16 +11,18 @@ for DICT in scripts/spelling/*.txt; do
done
OUT="$(mktemp)"
-shopt -s globstar
jekyll build --future --trace
-for f in _site/**/*.html; do
- if ! grep -E '^_site/vendor/' <(echo "$f") > /dev/null; then
+# shellcheck disable=2044
+for f in $(find _site -type f -name '*.html'); do
+ if ! echo "$f" | grep -E '^_site/vendor/' > /dev/null; then
l="$(head -n2 "$f" | tail -n1 | cut -d\" -f2)"
- hunspell -u3 -H -d "$l" -p <(cat scripts/spelling/international.txt "scripts/spelling/$l.txt") "$f" | tee -a "$OUT"
+ CURR_DICT="$(mktemp)"
+ cat scripts/spelling/international.txt "scripts/spelling/$l.txt" > "$CURR_DICT"
+ hunspell -u3 -H -d "$l" -p "$CURR_DICT" "$f" | tee -a "$OUT"
fi
done
-if [[ -s "$OUT" ]]; then
+if [ -s "$OUT" ]; then
printf "\nvvv Mispelled words detected by hunspell.\n\n"
cut -d\ -f2- < "$OUT" | sort | uniq
printf "\n^^^\n" >&2
diff --git a/scripts/extract-translations.sh b/scripts/extract-translations.sh
index 13fc160..ea4b0f5 100755
--- a/scripts/extract-translations.sh
+++ b/scripts/extract-translations.sh
@@ -1,14 +1,11 @@
-#!/usr/bin/env bash
-set -Eeuo pipefail
-cd "$(dirname "${BASH_SOURCE[0]}")"
-cd ../
+#!/bin/sh -eu
-TRANSLATIONS=(pt fr eo)
+TRANSLATIONS='pt fr eo'
for f in $(git ls-files | grep -E '.(md|slides)$' | grep -v '^vendor/reveal.js$'); do
file_lang="$(grep '^lang: ..$' "$f" | awk '{print $2}')"
- if [[ "$file_lang" = 'en' ]]; then
- for l in "${TRANSLATIONS[@]}"; do
+ if [ "$file_lang" = 'en' ]; then
+ for l in $TRANSLATIONS; do
OUT="locale/$l/LC_MESSAGES/${f%.md}.po"
mkdir -p "$(dirname "$OUT")"
md2po "$f" --include-codeblocks --quiet --save --po-filepath "$OUT"