Fix some shellcheck issues in init-po-files.

This commit is contained in:
Andrius Štikonas 2023-02-25 22:44:36 +08:00
parent 7dc1083e6a
commit dac5f5ff79
1 changed files with 25 additions and 24 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash -e
# Copyright (C) 2009 Andrius Štikonas <andrius@stikonas.eu> # Copyright (C) 2009 Andrius Štikonas <andrius@stikonas.eu>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
@ -14,11 +14,11 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
source "`dirname $0`/ths-variables" source "$(dirname "$0")/ths-variables"
source ".ths" source ".ths"
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo "Usage `basename $0` <messages-tree> <pot-tree>" echo "Usage $(basename "$0") <messages-tree> <pot-tree>"
exit 1 exit 1
fi fi
@ -30,28 +30,29 @@ else
pot="trunk-kf5/templates/messages" pot="trunk-kf5/templates/messages"
fi fi
wdir="`pwd`" wdir=$PWD
cd "$pot" cd "$pot"
for dir in `ls`; do for dir in */; do
cd "$dir" (
podir="$wdir/$messages/$dir" cd "$dir"
if [ ! -e "$podir" ]; then podir="$wdir/$messages/$dir"
mkdir "$podir" if [ ! -e "$podir" ]; then
svn add "$podir" mkdir "$podir"
fi svn add "$podir"
for file in `find . -name '*.pot'`; do fi
po=`echo $file | sed 's/.\{1\}$//'` for file in $(find . -name '*.pot'); do
if [ ! -e "$podir/$po" ]; then po=$(echo "$file" | sed 's/.\{1\}$//')
echo -e $RED"$dir/$po"$ENDCOLOR if [ ! -e "$podir/$po" ]; then
msginit -i "$file" -o "$podir/$po" --no-translator echo -e "${RED}${dir}/${po}${ENDCOLOR}"
cd "$podir" msginit -i "$file" -o "$podir/$po" --no-translator
svn add "$po" cd "$podir"
cd "$wdir/$pot/$dir" svn add "$po"
sed -ie 's/\"Plural-Forms: nplurals=3; plural=(n%10==1 \&\& n%100!=11 ? 0 : n%10>=2 \&\& (n"/"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n%10>=2 \&\& (n%100<10 || n"/ cd "$wdir/$pot/$dir"
sed -ie 's/\"Plural-Forms: nplurals=3; plural=(n%10==1 \&\& n%100!=11 ? 0 : n%10>=2 \&\& (n"/"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n%10>=2 \&\& (n%100<10 || n"/
s/\"%100<10 || n%100>=20) ? 1 : 2);\\n\"/"%100>=20) ? 1 : n%10==0 || (n%100>10 \&\& n%100<20) ? 2 : 3);\\n"/ s/\"%100<10 || n%100>=20) ? 1 : 2);\\n\"/"%100>=20) ? 1 : n%10==0 || (n%100>10 \&\& n%100<20) ? 2 : 3);\\n"/
/\"Language: lt\\n\"/d' "$podir/$po" /\"Language: lt\\n\"/d' "$podir/$po"
rm "$podir/$po"e rm "$podir/$po"e
fi fi
done done
cd .. )
done done