From 49e0da1d2a9c8d691530b836678ea83eda3df4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 10 Jun 2019 00:00:02 +0100 Subject: [PATCH] Fix some shellcheck warnings. --- compile | 10 ++-- pack | 38 +++++++------- statistics | 146 ++++++++++++++++++++++++++--------------------------- update | 34 ++++++------- 4 files changed, 114 insertions(+), 114 deletions(-) diff --git a/compile b/compile index 07ca597..24ed366 100755 --- a/compile +++ b/compile @@ -15,18 +15,18 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -source "`dirname $0`/variables" +source "$(dirname "$0")/variables" for BRANCH in $BRANCHES; do - echo -e "Repository: $BLUE$BRANCH"$ENDCOLOR + echo -e "Repository: $BLUE$BRANCH$ENDCOLOR" if [ ! -e "$MDIR/$BRANCH" ]; then mkdir -p "$MDIR/$BRANCH" fi - for file in `ls $BRANCH`; do + for file in $(ls "$BRANCH"); do echo "Compiling $file"; - $MSGFMT "$BRANCH/$file" -o "$MDIR/$BRANCH/`echo wesnoth-$file | sed "s/."$LCODE".po/.mo/" | sed "s/wesnoth-wesnoth/wesnoth/"`" + $MSGFMT "$BRANCH/$file" -o "$MDIR/$BRANCH/$(echo wesnoth-"$file" | sed "s/.$LCODE.po/.mo/" | sed "s/wesnoth-wesnoth/wesnoth/")" done rm "$MDIR/$BRANCH/wesnoth-manpages.mo" "$MDIR/$BRANCH/wesnoth-manual.mo" done -echo -e $GREEN"Finished."$ENDCOLOR +echo -e "${GREEN}Finished.$ENDCOLOR" diff --git a/pack b/pack index 9b42abd..7f2e1e3 100755 --- a/pack +++ b/pack @@ -15,32 +15,32 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -source "`dirname $0`/variables" +source "$(dirname "$0")/variables" counter=0 for BRANCH in $BRANCHES; do - echo -e "Checking out files from $BLUE$BRANCH"$ENDCOLOR - $GIT archive --remote $REPO --prefix=$BRANCH-temp/ --format=tar $BRANCH:po | tar x + echo -e "Checking out files from $BLUE$BRANCH$ENDCOLOR" + $GIT archive --remote "$REPO" --prefix="$BRANCH-temp/" --format=tar "$BRANCH:po" | tar x mkdir "$LCODE-temp" counter=0 - for file in `find $BRANCH -follow -name "*.$LCODE.po"`; do - bfile=`basename $file` + for file in $(find "$BRANCH" -follow -name "*.$LCODE.po"); do + bfile=$(basename "$file") echo -n "Processing catalog $bfile... "; - d=`echo "$bfile" | sed "s/.$LCODE.po//"` - dirdomain=`echo wesnoth-$d | sed "s/wesnoth-wesnoth/wesnoth/"` + d=${bfile//".$LCODE.po"/} + dirdomain=$(echo "wesnoth-$d" | sed "s/wesnoth-wesnoth/wesnoth/") if [ -f "$BRANCH-temp/$dirdomain/$LCODE.po" ]; then if ! $DIFF -q "$file" "$BRANCH-temp/$dirdomain/$LCODE.po" > /dev/null ; then mkdir "$LCODE-temp/$dirdomain" cp "$file" "$LCODE-temp/$dirdomain/$LCODE.po" - echo -e $GREEN"OK"$ENDCOLOR - counter=$(($counter+1)) + echo -e "${GREEN}OK$ENDCOLOR" + counter=$((counter+1)) else - echo -e $BLUE"Skipping"$ENDCOLOR + echo -e "${BLUE}Skipping$ENDCOLOR" fi else mkdir -p "$LCODE-temp/$dirdomain" cp "$file" "$LCODE-temp/$dirdomain/$LCODE.po" - echo -e $GREEN"OK"$ENDCOLOR - counter=$(($counter+1)) + echo -e "${GREEN}OK$ENDCOLOR" + counter=$((counter+1)) fi done @@ -50,14 +50,14 @@ for BRANCH in $BRANCHES; do fi if [ ! $counter -eq 0 ]; then - cd $LCODE-temp - $TAR --remove-files -cf ../$LCODE-$BRANCH.tar wesnoth* - cd .. - $BZIP -9 $LCODE-$BRANCH.tar + cd "$LCODE-temp" || exit + $TAR --remove-files -cf "../$LCODE-$BRANCH.tar" wesnoth* + cd .. || exit + $BZIP -9 "$LCODE-$BRANCH.tar" echo "New archive created." fi - rm -rf $BRANCH-temp - rmdir $LCODE-temp + rm -rf "$BRANCH-temp" + rmdir "$LCODE-temp" done -echo -e $GREEN"Finished."$ENDCOLOR +echo -e "${GREEN}Finished.$ENDCOLOR" diff --git a/statistics b/statistics index b0b986c..9dc99b1 100755 --- a/statistics +++ b/statistics @@ -31,11 +31,11 @@ while getopts ":c" opt; do done for BRANCH in $BRANCHES; do - echo -e "Repository: $BLUE$BRANCH"$ENDCOLOR + echo -e "Repository: $BLUE$BRANCH$ENDCOLOR" STATSFILE="statistics-$BRANCH.html" ERRORS="translation-errors-$BRANCH" nerror=0; nwarn=0; npo=0; nt=0; nu=0; nf=0 - rm -f $STATSFILE + rm -f "$STATSFILE" echo -e " @@ -88,62 +88,62 @@ $(LC_TIME="en_US.UTF-8" date) % Total Graph - " >> $STATSFILE + " >> "$STATSFILE" if [ -n "$CORE_TEXTDOMAINS" ]; then - POFILES=$BRANCH/$(echo $CORE_TEXTDOMAINS | awk '$NF=$NF "*.po"' OFS="*.po $BRANCH/") + POFILES=$BRANCH/$(echo "$CORE_TEXTDOMAINS" | awk '$NF=$NF "*.po"' OFS="*.po $BRANCH/") else POFILES="$BRANCH/*.po" fi for files in $POFILES; do - file=$(basename $files) - filename=$(basename $file .po) - npo=$(($npo + 1)); has_errors="no"; has_warnings="no"; + file=$(basename "$files") + filename=$(basename "$file" .po) + npo=$((npo + 1)); has_errors="no"; has_warnings="no"; # Extract the declared charset, may be we use this in future. charset=$(sed -n '/^"Content-Type:/ s/.*charset=\([a-zA-Z0-9_-]*\).*/\1/p' "$BRANCH/$file") echo -n "Checking $file for UTF-8 inconsistencies... " if $ISUTF8 < "$BRANCH/$file" > /dev/null 2>&1; then - if ! echo $charset | grep -qi "UTF-8"; then + if ! echo "$charset" | grep -qi "UTF-8"; then has_errors="yes" - echo -e $RED"FAILED; non UTF-8 charset declaration for UTF-8 content"$ENDCOLOR - echo "$file: non UTF-8 charset declared for UTF-8 content; expect to see 'charset=UTF-8'." >> $ERRORS + echo -e "${RED}FAILED; non UTF-8 charset declaration for UTF-8 content$ENDCOLOR" + echo "$file: non UTF-8 charset declared for UTF-8 content; expect to see 'charset=UTF-8'." >> "$ERRORS" else - echo -e $GREEN"OK"$ENDCOLOR + echo -e "${GREEN}OK$ENDCOLOR" fi else - if echo $charset | grep -qi "UTF-8"; then + if echo "$charset" | grep -qi "UTF-8"; then has_errors="yes" - echo -e $RED"FAILED; non UTF-8 content for UTF-8 charset declaration"$ENDCOLOR - echo "$file: UTF-8 charset declared for non UTF-8 content; expect to see a non UTF-8 charset." >> $ERRORS + echo -e "${RED}FAILED; non UTF-8 content for UTF-8 charset declaration$ENDCOLOR" + echo "$file: UTF-8 charset declared for non UTF-8 content; expect to see a non UTF-8 charset." >> "$ERRORS" else - echo -e $GREEN"OK"$ENDCOLOR + echo -e "${GREEN}OK$ENDCOLOR" fi fi - + echo -n "Checking $file for odd characters... " - if grep -nH $ODD_CHARS "$BRANCH/$file" >> $ERRORS; then + if grep -nH $ODD_CHARS "$BRANCH/$file" >> "$ERRORS"; then has_warnings="yes" - echo -e $RED"FAILED; odd characters found"$ENDCOLOR - echo "$file: one or more odd character from the '$ODD_CHARS' set found." >> $ERRORS + echo -e "${RED}FAILED; odd characters found$ENDCOLOR" + echo "$file: one or more odd character from the '$ODD_CHARS' set found." >> "$ERRORS" else - echo -e $GREEN"OK"$ENDCOLOR + echo -e "${GREEN}OK$ENDCOLOR" fi # Makes sense only if the file passed the UTF-8 check. if [ "$has_errors" = "no" ]; then echo -n "Checking $file with msgfmt... " - if ! LC_MESSAGES=C $MSGFMT --check -o /dev/null "$BRANCH/$file" >> $ERRORS; then + if ! LC_MESSAGES=C $MSGFMT --check -o /dev/null "$BRANCH/$file" >> "$ERRORS"; then has_errors="yes" - echo -e $RED"FAILED"$ENDCOLOR + echo -e "${RED}FAILED$ENDCOLOR" else - echo -e $GREEN"OK"$ENDCOLOR + echo -e "${GREEN}OK$ENDCOLOR" fi fi - r=0; rf=0; ru=0; t=0; u=0; f=0; rt=0 + rf=0; ru=0; t=0; u=0; f=0; rt=0 if [ "$has_errors" = "yes" ]; then - nerror=$(($nerror + 1)) + nerror=$((nerror + 1)) sum=0 st="Error" if [ $STATUS = "OK" ]; then @@ -157,25 +157,25 @@ $(LC_TIME="en_US.UTF-8" date) t=$(echo "$stat" | sed -ne 's/\([0-9]\+\) translated .*/\1/p'); t=${t:-0} u=$(echo "$stat" | sed -ne 's/.* \([0-9]\+\) untranslated .*/\1/p'); u=${u:-0} f=$(echo "$stat" | sed -ne 's/.* \([0-9]\+\) fuzzy translation.*/\1/p'); f=${f:-0} - - sum=$(($t + $f + $u)) + + sum=$((t + f + u)) if [ ! "$sum" -eq 0 ]; then - rt=$(printf '%s%d%s%d\n' "scale=2; 100*" $t "/" $sum | bc) + rt=$(printf '%s%d%s%d\n' "scale=2; 100*" "$t" "/" $sum | bc) fi if [ ! "$sum" -eq 0 ]; then - rf=$(printf '%s%d%s%d\n' "scale=2; 100*" $f "/" $sum | bc) + rf=$(printf '%s%d%s%d\n' "scale=2; 100*" "$f" "/" $sum | bc) fi - + if [ ! "$sum" -eq 0 ]; then - ru=$(printf '%s%d%s%d\n' "scale=2; 100*" $u "/" $sum | bc) + ru=$(printf '%s%d%s%d\n' "scale=2; 100*" "$u" "/" $sum | bc) fi - - nt=$(($nt + $t)); nu=$(($nu + $u)); nf=$(($nf + $f)) - + + nt=$((nt + t)); nu=$((nu + u)); nf=$((nf + f)) + st="OK" if [ "$has_warnings" = "yes" ]; then - nwarn=$(($nwarn + 1)) + nwarn=$((nwarn + 1)) st='Warning' if [ "$STATUS" = "OK" ]; then STATUS='Warning' @@ -183,53 +183,53 @@ $(LC_TIME="en_US.UTF-8" date) fi fi - echo "" >> $STATSFILE - CL=$(( ($CL+1)%2 )) - echo " $(basename $filename) + echo "" >> "$STATSFILE" + CL=$(( (CL+1)%2 )) + echo " $(basename "$filename") $st - $t" >> $STATSFILE - printf '%s%.2f%s\n' " " $rt "" >> $STATSFILE - echo " $f" >> $STATSFILE - printf '%s%.2f%s\n' " " $rf "" >> $STATSFILE - echo " $u" >> $STATSFILE - printf '%s%.2f%s\n' " " $ru "" >> $STATSFILE - echo " $sum" >> $STATSFILE - n4=$(printf '%s%f\n' "scale=2; 9*" $rt | bc) - n6=$(printf '%s%f\n' "scale=2; 9*" $rf | bc) - n8=$(printf '%s%f\n' "scale=2; 9*" $ru | bc) - printf '%s%.2f%s%.2f%s%.2f%s\n' " " >> $STATSFILE - echo "" >> $STATSFILE + $t" >> "$STATSFILE" + printf '%s%.2f%s\n' " " "$rt" "" >> "$STATSFILE" + echo " $f" >> "$STATSFILE" + printf '%s%.2f%s\n' " " "$rf" "" >> "$STATSFILE" + echo " $u" >> "$STATSFILE" + printf '%s%.2f%s\n' " " "$ru" "" >> "$STATSFILE" + echo " $sum" >> "$STATSFILE" + n4=$(printf '%s%f\n' "scale=2; 9*" "$rt" | bc) + n6=$(printf '%s%f\n' "scale=2; 9*" "$rf" | bc) + n8=$(printf '%s%f\n' "scale=2; 9*" "$ru" | bc) + printf '%s%.2f%s%.2f%s%.2f%s\n' " " >> "$STATSFILE" + echo "" >> "$STATSFILE" done if [ "$npo" -eq 0 ]; then - echo -e $RED"No '${PO}.po' file under '$BRANCH'."$ENDCOLOR + echo -e "${RED}No '${PO}.po' file under '$BRANCH'.$ENDCOLOR" exit 0 fi if [ "$nerror" -gt 0 ]; then - echo -n -e $RED"Fatal errors found. See '" + echo -n -e "${RED}Fatal errors found. See '" tput smso; echo -n "$ERRORS"; tput rmso - echo -ne "' for details."$ENDCOLOR + echo -ne "' for details.$ENDCOLOR" echo "" else - echo -ne $GREEN"No fatal errors found."$ENDCOLOR + echo -ne "${GREEN}No fatal errors found.$ENDCOLOR" echo "" if [ -s "$ERRORS" ]; then - echo -n -e $RED" See '" + echo -n -e "$RED See '" tput smso; echo -n "$ERRORS"; tput rmso - echo -ne "' for warnings."$ENDCOLOR + echo -ne "' for warnings.$ENDCOLOR" echo "" else - rm -f $ERRORS + rm -f "$ERRORS" fi fi if [ "$npo" = "$nerror" ]; then - echo -en $RED"All files have fatal errors."$ENDCOLOR + echo -en "${RED}All files have fatal errors.$ENDCOLOR" echo "" else - sum=$((${nt} + ${nf} + ${nu})) + sum=$((nt + nf + nu)) nrt=$(printf '%s%d%s%d\n' "scale=2; 100*" $nt "/" $sum | bc) nrf=$(printf '%s%d%s%d\n' "scale=2; 100*" $nf "/" $sum | bc) nru=$(printf '%s%d%s%d\n' "scale=2; 100*" $nu "/" $sum | bc) @@ -237,20 +237,20 @@ $(LC_TIME="en_US.UTF-8" date) echo " Total $STATUS -$nt" >> $STATSFILE - printf '%s%.2f%s\n' "" $nrt "" >> $STATSFILE - echo "$nf" >> $STATSFILE - printf '%s%.2f%s\n' "" $nrf "" >> $STATSFILE - echo "$nu" >> $STATSFILE - printf '%s%.2f%s\n' "" $nru "" >> $STATSFILE - echo "$((${nt} + ${nf} + ${nu}))" >> $STATSFILE +$nt" >> "$STATSFILE" + printf '%s%.2f%s\n' "" "$nrt" "" >> "$STATSFILE" + echo "$nf" >> "$STATSFILE" + printf '%s%.2f%s\n' "" "$nrf" "" >> "$STATSFILE" + echo "$nu" >> "$STATSFILE" + printf '%s%.2f%s\n' "" "$nru" "" >> "$STATSFILE" + echo "$((nt + nf + nu))" >> "$STATSFILE" - nrt=$(printf '%s%f\n' "scale=2; 9*" $nrt | bc) - nrf=$(printf '%s%f\n' "scale=2; 9*" $nrf | bc) - nru=$(printf '%s%f\n' "scale=2; 9*" $nru | bc) + nrt=$(printf '%s%f\n' "scale=2; 9*" "$nrt" | bc) + nrf=$(printf '%s%f\n' "scale=2; 9*" "$nrf" | bc) + nru=$(printf '%s%f\n' "scale=2; 9*" "$nru" | bc) - printf '%s%.2f%s%.2f%s%.2f%s\n' " " >> $STATSFILE - + printf '%s%.2f%s%.2f%s%.2f%s\n' " " >> "$STATSFILE" + echo " @@ -259,14 +259,14 @@ $(LC_TIME="en_US.UTF-8" date)

-© 2003-"$(date +%Y)" The Battle for Wesnoth
+© 2003-$(date +%Y) The Battle for Wesnoth
Site design Copyright © 2017–2018 by Iris Morelle.
-" >> $STATSFILE +" >> "$STATSFILE" fi done diff --git a/update b/update index 1a3639d..9d4f991 100755 --- a/update +++ b/update @@ -15,38 +15,38 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -source "`dirname $0`/variables" +source "$(dirname "$0")/variables" -echo -e "Language: $RED$LCODE"$ENDCOLOR +echo -e "Language: $RED$LCODE$ENDCOLOR" for BRANCH in $BRANCHES; do - echo -e "Checking out files from $BLUE$BRANCH"$ENDCOLOR + echo -e "Checking out files from $BLUE$BRANCH$ENDCOLOR" if [ ! -e "$BRANCH" ]; then mkdir "$BRANCH" fi - $GIT archive --remote $REPO --prefix="$BRANCH-temp/" --format=tar "$BRANCH:po" | tar x - for dir in `ls "$BRANCH-temp/wesnoth"* -d`; do - echo "Processing `basename $dir | sed s/wesnoth-//`.$LCODE.po" - file="$BRANCH/`basename $dir | sed s/wesnoth-//`.$LCODE.po" - if [ -f $dir"/"$LCODE".po" ]; then + "$GIT" archive --remote "$REPO" --prefix="$BRANCH-temp/" --format=tar "$BRANCH:po" | tar x + for dir in $(ls "$BRANCH-temp/wesnoth"* -d); do + echo "Processing $(basename "$dir" | sed s/wesnoth-//).$LCODE.po" + file="$BRANCH/$(basename "$dir" | sed s/wesnoth-//).$LCODE.po" + if [ -f "$dir""/$LCODE"".po" ]; then if [ -f "$file" ]; then - echo -e $BLUE"Merging:"$ENDCOLOR - $MSGMERGE -U -v "$file" "$dir/`basename $dir`.pot" - rm -f $file~ + echo -e "${BLUE}Merging:$ENDCOLOR" + $MSGMERGE -U -v "$file" "$dir/$(basename "$dir").pot" + rm -f "$file~" else - echo -e $RED"Copying:"$ENDCOLOR + echo -e "${RED}Copying:$ENDCOLOR" cp "$dir/$LCODE.po" "$file" fi else - if [ ! -f $file ]; then - echo -e $RED"No po file in repository. Running msginit."$ENDCOLOR + if [ ! -f "$file" ]; then + echo -e "${RED}No po file in repository. Running msginit.$ENDCOLOR" echo "$dir" - $MSGINIT -i "$dir/`basename $dir`.pot" -o $file + "$MSGINIT" -i "$dir/$(basename "$dir").pot" -o "$file" else - echo -e $RED"No po file in repository. Found file in workspace."$ENDCOLOR + echo -e "${RED}No po file in repository. Found file in workspace.$ENDCOLOR" fi fi echo "" done rm -rf "$BRANCH-temp" done -echo -e $GREEN"Finished."$ENDCOLOR +echo -e "${GREEN}Finished.$ENDCOLOR"