From 2104b563d61233fcf537f7abbd20fce334cac2a7 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 21 Jun 2018 12:49:45 +1000 Subject: [PATCH] Fix some SC2086 warnings --- .ci/travis/linux/script.sh | 4 +-- .ci/travis/macos/script.sh | 2 +- scripts/customwidget_create.sh | 2 +- scripts/prepare-commit.sh | 50 +++++++++++++++++----------------- scripts/replacev2.sh | 34 +++++++++++------------ scripts/sort_include.sh | 2 +- 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/.ci/travis/linux/script.sh b/.ci/travis/linux/script.sh index 973baea7fbea..e62e47ae753a 100755 --- a/.ci/travis/linux/script.sh +++ b/.ci/travis/linux/script.sh @@ -20,14 +20,14 @@ source $(git rev-parse --show-toplevel)/.ci/travis/scripts/travis_envvar_helper. DOCKER_QGIS_IMAGE_BUILD_PUSH=$(create_qgis_image) -mkdir -p $CCACHE_DIR +mkdir -p "$CCACHE_DIR" if [[ $DOCKER_QGIS_IMAGE_BUILD_PUSH =~ true ]]; then DIR=$(git rev-parse --show-toplevel)/.docker pushd "${DIR}" echo "${bold}Building QGIS Docker image '${DOCKER_TAG}'...${endbold}" docker build --build-arg CACHE_DIR=/root/.ccache \ - --build-arg DOCKER_TAG=${DOCKER_TAG} \ + --build-arg DOCKER_TAG="${DOCKER_TAG}" \ --cache-from "qgis/qgis:${DOCKER_TAG}" \ -t "qgis/qgis:${DOCKER_TAG}" \ -f qgis.dockerfile .. diff --git a/.ci/travis/macos/script.sh b/.ci/travis/macos/script.sh index cc55f7326992..523629f18cd2 100755 --- a/.ci/travis/macos/script.sh +++ b/.ci/travis/macos/script.sh @@ -33,7 +33,7 @@ TIMEOUT=$((40 * 60 - $(date +%s) + $(cat /tmp/travis_timestamp))) export CTEST_BUILD_COMMAND=/usr/local/bin/ninja export CTEST_BUILD_DIR=${TRAVIS_BUILD_DIR} -gtimeout "${TIMEOUT}s" ctest -V -E "$(cat ${DIR}/blacklist.txt | gsed -r '/^(#.*?)?$/d' | gpaste -sd '|' -)" -S "${DIR}/../travis.ctest" --output-on-failure +gtimeout "${TIMEOUT}s" ctest -V -E "$(cat "${DIR}"/blacklist.txt | gsed -r '/^(#.*?)?$/d' | gpaste -sd '|' -)" -S "${DIR}/../travis.ctest" --output-on-failure rv=$? diff --git a/scripts/customwidget_create.sh b/scripts/customwidget_create.sh index e58a8f69000a..282af0641ef0 100755 --- a/scripts/customwidget_create.sh +++ b/scripts/customwidget_create.sh @@ -26,7 +26,7 @@ declare -a EXT=("cpp" "h") for i in "${EXT[@]}" do DESTFILE=$DIR/../src/customwidgets/${CLASSLOWER}plugin.$i - cp $DIR/customwidget.$i.template $DESTFILE + cp "$DIR"/customwidget."$i".template "$DESTFILE" sed -i s/%DATE%/"$TODAY"/g "$DESTFILE" sed -i s/%YEAR%/"$YEAR"/g "$DESTFILE" sed -i s/%AUTHOR%/"$AUTHOR"/g "$DESTFILE" diff --git a/scripts/prepare-commit.sh b/scripts/prepare-commit.sh index b7f1fe9e3d8c..2ee7b24251fb 100755 --- a/scripts/prepare-commit.sh +++ b/scripts/prepare-commit.sh @@ -22,7 +22,7 @@ if ! tty -s && [[ "$0" =~ /pre-commit ]]; then exec sha-$REV.diff +git diff >sha-"$REV".diff ASTYLEDIFF=astyle.$REV.diff -true > $ASTYLEDIFF +true > "$ASTYLEDIFF" # reformat i=0 -N=$(echo $MODIFIED | wc -w) +N=$(echo "$MODIFIED" | wc -w) for f in $MODIFIED; do (( i++ )) || true case "$f" in src/core/gps/qextserialport/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*|src/3d/poly2tri/*) - echo $f skipped + echo "$f" skipped continue ;; @@ -89,59 +89,59 @@ for f in $MODIFIED; do m=$f.$REV.prepare - cp $f $m - ASTYLEPROGRESS=" [$i/$N]" astyle.sh $f - if diff -u $m $f >>$ASTYLEDIFF; then + cp "$f" "$m" + ASTYLEPROGRESS=" [$i/$N]" astyle.sh "$f" + if diff -u "$m" "$f" >>"$ASTYLEDIFF"; then # no difference found - rm $m + rm "$m" fi done if [ -s "$ASTYLEDIFF" ]; then if tty -s; then # review astyle changes - colordiff <$ASTYLEDIFF | less -r + colordiff <"$ASTYLEDIFF" | less -r else echo "Files changed (see $ASTYLEDIFF)" fi else - rm $ASTYLEDIFF + rm "$ASTYLEDIFF" fi # verify SIP files SIPIFYDIFF=sipify.$REV.diff -true > $SIPIFYDIFF +true > "$SIPIFYDIFF" for f in $MODIFIED; do # if cpp header if [[ $f =~ ^src\/(core|gui|analysis|server)\/.*\.h$ ]]; then # look if corresponding SIP file - sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)/@@; s@\.h$@.sip@' <<<$f ) - pyfile=$(${GP}sed -E 's@([^\/]+\/)*([^\/]+)\.sip@\2.py@;' <<< $sip_file) - module=$(${GP}sed -r 's@src/(core|gui|analysis|server)/.*$@\1@' <<<$f ) - if grep -Fq "$sip_file" ${TOPLEVEL}/python/${module}/${module}_auto.sip; then - sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)@\1/auto_generated@; s@\.h$@.sip.in@' <<<$f ) + sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)/@@; s@\.h$@.sip@' <<<"$f" ) + pyfile=$(${GP}sed -E 's@([^\/]+\/)*([^\/]+)\.sip@\2.py@;' <<< "$sip_file") + module=$(${GP}sed -r 's@src/(core|gui|analysis|server)/.*$@\1@' <<<"$f" ) + if grep -Fq "$sip_file" "${TOPLEVEL}"/python/"${module}"/"${module}"_auto.sip; then + sip_file=$(${GP}sed -r 's@^src/(core|gui|analysis|server)@\1/auto_generated@; s@\.h$@.sip.in@' <<<"$f" ) m=python/$sip_file.$REV.prepare - touch python/$sip_file - cp python/$sip_file $m - ${TOPLEVEL}/scripts/sipify.pl -s python/$sip_file -p python/${module}/auto_additions/${pyfile} $f - if ! diff -u $m python/$sip_file >>$SIPIFYDIFF; then + touch python/"$sip_file" + cp python/"$sip_file" "$m" + "${TOPLEVEL}"/scripts/sipify.pl -s python/"$sip_file" -p python/"${module}"/auto_additions/"${pyfile}" "$f" + if ! diff -u "$m" python/"$sip_file" >>"$SIPIFYDIFF"; then echo "python/$sip_file is not up to date" fi - rm $m + rm "$m" fi fi done if [[ -s "$SIPIFYDIFF" ]]; then if tty -s; then # review astyle changes - colordiff <$SIPIFYDIFF | less -r + colordiff <"$SIPIFYDIFF" | less -r else echo "Files changed (see $ASTYLEDIFF)" fi exit 1 else - rm $SIPIFYDIFF + rm "$SIPIFYDIFF" fi if [ -s "$ASTYLEDIFF" ]; then exit 1 diff --git a/scripts/replacev2.sh b/scripts/replacev2.sh index 3d075e407240..5a97ba1486e4 100755 --- a/scripts/replacev2.sh +++ b/scripts/replacev2.sh @@ -9,40 +9,40 @@ r=$(mktemp -t repl.XXXX.pl) d=$(mktemp -t apibreak.XXXX.txt) # Rename classes -for i in $(git --no-pager grep "Qgs[a-zA-Z0-9_]*V2" $codepaths | perl -pe 's#^.*(Qgs[a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | sort -u) +for i in $(git --no-pager grep "Qgs[a-zA-Z0-9_]*V2" "$codepaths" | perl -pe 's#^.*(Qgs[a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | sort -u) do src=$i dst=${src/V2/} - if git --no-pager grep -l "\<$dst\>" $codepaths; then - echo "$src vs $dst" >>$s + if git --no-pager grep -l "\<$dst\>" "$codepaths"; then + echo "$src vs $dst" >>"$s" else echo " REPLACE $src => $dst" - echo "s/\b$src\b/$dst/g;" >>$r - echo "s/\bsipType_$src\b/sipType_$dst/;" >>$r - echo "$src$dst" >>$d + echo "s/\b$src\b/$dst/g;" >>"$r" + echo "s/\bsipType_$src\b/sipType_$dst/;" >>"$r" + echo "$src$dst" >>"$d" fi done -for i in $(git --no-pager grep "::[a-zA-Z0-9_]*V2" $codepaths | perl -pe 's#^.*::([a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | grep -v -E "^Qgs|SslV2" | sort -u) +for i in $(git --no-pager grep "::[a-zA-Z0-9_]*V2" "$codepaths" | perl -pe 's#^.*::([a-zA-Z0-9_]*)V2([a-zA-Z0-9_]*).*$#$1V2$2#' | grep -v -E "^Qgs|SslV2" | sort -u) do src=$i dst=${src/V2/} - if git --no-pager grep -l "\<$dst\>" $codepaths; then - echo "$src vs $dst" >>$s + if git --no-pager grep -l "\<$dst\>" "$codepaths"; then + echo "$src vs $dst" >>"$s" else echo " REPLACE $src => $dst" - echo "s/\b$src\b/$dst/g;" >>$r - echo "$src$dst" >>$d + echo "s/\b$src\b/$dst/g;" >>"$r" + echo "$src$dst" >>"$d" fi done -find $codepaths \( -name "*v2*.h" -o -name "*v2*.cpp" -o -name "*v2*.sip" \) -type f | while read f; do +find "$codepaths" \( -name "*v2*.h" -o -name "*v2*.cpp" -o -name "*v2*.sip" \) -type f | while read f; do s=${f##*/} d=${s/v2/} echo "FIND $d" - if [ $(find $codepaths -name "$d" -print | wc -l) -gt 0 ]; then - echo "$f vs $b" >>$s + if [ $(find "$codepaths" -name "$d" -print | wc -l) -gt 0 ]; then + echo "$f vs $b" >>"$s" continue fi @@ -50,11 +50,11 @@ find $codepaths \( -name "*v2*.h" -o -name "*v2*.cpp" -o -name "*v2*.sip" \) -ty case "$s" in *.sip) - echo "s#\b$s\b#$d#g;" >>$r + echo "s#\b$s\b#$d#g;" >>"$r" ;; *) - echo "s#\b$s\b#$d#g;" >>$r + echo "s#\b$s\b#$d#g;" >>"$r" ;; esac done @@ -62,4 +62,4 @@ done echo "API breaks logged to: $d" echo "Skipped V2 symbols: $s" echo "Replacing from $r" -find $codepaths -type f | xargs perl -i -p $r +find "$codepaths" -type f | xargs perl -i -p "$r" diff --git a/scripts/sort_include.sh b/scripts/sort_include.sh index 994f0bca38e9..b48e8f1b2c7a 100755 --- a/scripts/sort_include.sh +++ b/scripts/sort_include.sh @@ -73,7 +73,7 @@ do sort -u $FILE3 >> $FILE1 SORTING=false fi - mv $FILE1 $file + mv $FILE1 "$file" rm -f $FILE1 $FILE2 $FILE3 done