From 4ada4a57863bef98330b94fb7373b9e88c035140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 26 Feb 2023 00:27:22 +0800 Subject: [PATCH] More shellcheck fixes. --- backport | 18 +++++++++--------- checkout | 10 +++++----- obsolete | 2 +- pack-po-files | 4 ++-- pocompare | 12 ++++++------ pocompare-kdiff3 | 12 ++++++------ potopot | 16 ++++++++-------- stripfuzzy | 16 ++++++++-------- 8 files changed, 45 insertions(+), 45 deletions(-) diff --git a/backport b/backport index 9d1d9c8..22a0c99 100755 --- a/backport +++ b/backport @@ -1,6 +1,6 @@ -#!/bin/bash +#!/bin/bash -e -source "`dirname $0`/ths-variables" +source "$(dirname "$0")/ths-variables" function jobidfromstring() { @@ -8,22 +8,22 @@ function jobidfromstring() local RET; STRING=$1; - RET="$(echo $STRING | sed 's/^[^0-9]*//' | sed 's/[^0-9].*$//')" + RET="$(echo "$STRING" | sed 's/^[^0-9]*//' | sed 's/[^0-9].*$//')" - echo $RET; + echo "$RET"; } -echo -e $BLUE"Running poupdate..."$ENDCOLOR +echo -e "${BLUE}Running poupdate...${ENDCOLOR}" ./poupdate -NS --silent trunk-kf5/$lcode/messages stable-kf5/$lcode/messages stable-kf5/templates/messages & -LASTJOB=`jobidfromstring $(jobs %%)` +LASTJOB=$(jobidfromstring "$(jobs %%)") JOBLIST="$LASTJOB" ./poupdate -NS --silent trunk-kf5/$lcode/docmessages stable-kf5/$lcode/docmessages stable-kf5/templates/docmessages & -LASTJOB=`jobidfromstring $(jobs %%)` +LASTJOB=$(jobidfromstring "$(jobs %%)") JOBLIST="$JOBLIST $LASTJOB" for JOB in $JOBLIST ; do - wait %$JOB + wait %"$JOB" done -echo -e $BLUE"Removing obsolete entries..."$ENDCOLOR +echo -e "${BLUE}Removing obsolete entries...${ENDCOLOR}" ./obsolete stable-kf5/$lcode/messages ./obsolete stable-kf5/$lcode/docmessages diff --git a/checkout b/checkout index 8aa6d06..acca551 100755 --- a/checkout +++ b/checkout @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # Copyright (C) 2009 Andrius Štikonas # # This program is free software: you can redistribute it and/or modify @@ -18,7 +18,7 @@ source "`dirname $0`/ths-variables" if [ ! -f ".ths" ]; then echo "Please enter your language code (Default: lt):" - read lcode + read -r lcode if [ ! "$lcode" ]; then lcode="lt" fi @@ -26,9 +26,9 @@ if [ ! -f ".ths" ]; then while [ ! "$svnwrite" = "n" ] && [ ! "$svnwrite" = "y" ]; do echo "Do you have write access to KDE svn repository? [y/N]" - read svnwrite - svnwrite=`echo $svnwrite | tr YN yn` - if [ ! $svnwrite ]; then + read -r svnwrite + svnwrite=$(echo $svnwrite | tr YN yn) + if [ ! "$svnwrite" ]; then svnwrite="n" fi done diff --git a/obsolete b/obsolete index 542dd3b..1401b2d 100755 --- a/obsolete +++ b/obsolete @@ -26,4 +26,4 @@ else folder="trunk-kf5/$lcode/messages" fi -posieve remove-obsolete $folder +posieve remove-obsolete "$folder" diff --git a/pack-po-files b/pack-po-files index 813daa5..21f5123 100755 --- a/pack-po-files +++ b/pack-po-files @@ -16,5 +16,5 @@ source ".ths" -tar cfvj trunk.tar.bz2 `svn status trunk-kf5/$lcode | awk '{print $2}'` -tar cfvj stable.tar.bz2 `svn status trunk-kf5/$lcode | awk '{print $2}'` \ No newline at end of file +tar cfvj trunk.tar.bz2 "$(svn status trunk-kf5/$lcode | awk '{print $2}')" +tar cfvj stable.tar.bz2 "$(svn status trunk-kf5/$lcode | awk '{print $2}')" diff --git a/pocompare b/pocompare index fa323f0..03f0a60 100755 --- a/pocompare +++ b/pocompare @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # # Copyright 2007, Donatas Glodenis # @@ -20,14 +20,14 @@ # for best comparison. if [ $# -ne 2 ]; then - echo "Usage `basename $0` " + echo "Usage $(basename "$0") " exit 1 fi file1=$1 file2=$2 -msgmerge --no-wrap $file1 $file1 -o ${file1}.for.diff -msgmerge --no-wrap $file2 $file2 -o ${file2}.for.diff -diff ${file1}.for.diff ${file2}.for.diff -rm ${file1}.for.diff ${file2}.for.diff +msgmerge --no-wrap "$file1" "$file1" -o "${file1}.for.diff" +msgmerge --no-wrap "$file2" "$file2" -o "${file2}.for.diff" +diff "${file1}.for.diff" "${file2}.for.diff" +rm "${file1}.for.diff" "${file2}.for.diff" diff --git a/pocompare-kdiff3 b/pocompare-kdiff3 index 6c86e6f..582d85b 100755 --- a/pocompare-kdiff3 +++ b/pocompare-kdiff3 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # # Copyright 2007, Donatas Glodenis # @@ -20,14 +20,14 @@ # unwrapps first for best comparison. if [ $# -ne 2 ]; then - echo "Usage `basename $0` " + echo "Usage $(basename "$0") " exit 1 fi file1=$1 file2=$2 -msgmerge --no-wrap $file1 $file1 -o ${file1}.for.diff -msgmerge --no-wrap $file2 $file2 -o ${file2}.for.diff -kdiff3 ${file1}.for.diff ${file2}.for.diff -rm ${file1}.for.diff ${file2}.for.diff +msgmerge --no-wrap "$file1" "$file1" -o "${file1}.for.diff" +msgmerge --no-wrap "$file2" "$file2" -o "${file2}.for.diff" +kdiff3 "${file1}.for.diff" "${file2}.for.diff" +rm "${file1}.for.diff" "${file2}.for.diff" diff --git a/potopot b/potopot index 8ef6c63..0e04468 100755 --- a/potopot +++ b/potopot @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # # Copyright 2007, Donatas Glodenis # @@ -20,7 +20,7 @@ # strips all the translation). if [ $# -ne 1 ]; then - echo "Usage: `basename $0` " + echo "Usage: $(basename "$0") " exit 1 fi @@ -33,24 +33,24 @@ sleep 3 echo "Creating directory ${pofiles}/templates/ ... " -mkdir $pofiles/templates +mkdir "$pofiles/templates" sleep 1 -for file in `cd $pofiles; find . -name "*.po"` +for file in $(cd "$pofiles"; find . -name "*.po") do echo -n "Working on ${file}. Unwrapping..." # unwrap messages for cleaner operation - msgmerge --no-wrap ${pofiles}/$file $pofiles/$file -o $pofiles/$file + msgmerge --no-wrap "${pofiles}/$file $pofiles/$file" -o "$pofiles/$file" # remove the translations and creating pot files echo "Cleaning up translations..." - msgfilter --input=$pofiles/$file --output-file=$pofiles/templates/${file}t --keep-header sed --expression='s/.*//' ; echo "done." + msgfilter --input="$pofiles/$file" --output-file="$pofiles/templates/${file}t" --keep-header sed --expression='s/.*//' ; echo "done." # applying some more filters via sed: remove remaining \n signs (sed 1 and 2), removing the fuzzy headers (3), removing the empty "" (4), removing the extra empty lines (5) echo "Applying additional filter..." - cat $pofiles/templates/${file}t | sed -e 's/msgstr \"\\n\"/msgstr \"\"/' | \ + cat "$pofiles/templates/${file}t" | sed -e 's/msgstr \"\\n\"/msgstr \"\"/' | \ sed -e 's/\"\\n\"/\"\"/' | \ sed -e 's/#, fuzzy//' | \ sed -e 's/^""//' | \ - sed '/./,/^$/!d' > $pofiles/templates/${file}t ; echo "done." + sed '/./,/^$/!d' > "$pofiles/templates/${file}t" ; echo "done." echo "File ${file}t in directory templates/ created." echo done diff --git a/stripfuzzy b/stripfuzzy index 782ee20..124f369 100755 --- a/stripfuzzy +++ b/stripfuzzy @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # # Copyright 2007, Donatas Glodenis # @@ -19,7 +19,7 @@ # ths-stripfuzzy.sh - makes all fuzzy strings non-fuzzy in a translation project. if [ $# -ne 2 ]; then - echo "Usage `basename $0` " + echo "Usage $(basename "$0") " exit 1 fi @@ -27,16 +27,16 @@ pofiles=$1 templates=$2 echo "Completely removing the fuzzy strings from the pofiles..." -for po in `cd $pofiles ; find . -name "*.po"` +for po in $(cd "$pofiles" ; find . -name "*.po") do - echo -n $pofiles/$po - msgattrib -o $pofiles/$po --no-fuzzy $pofiles/$po + echo -n "$pofiles/$po" + msgattrib -o "$pofiles/$po" --no-fuzzy "$pofiles/$po" done echo "Restoring the previously fuzzy as untranslated strings..." -for po in `cd $pofiles ; find . -name "*.po"` +for po in $(cd "$pofiles" ; find . -name "*.po") do - echo -n $pofiles/$po - msgmerge --no-fuzzy-matching --backup=off --update $pofiles/$po $templates/${po}t + echo -n "$pofiles/$po" + msgmerge --no-fuzzy-matching --backup=off --update "$pofiles/$po" "$templates/${po}t" done