Skip to content

Commit

Permalink
Fix some shellcheck warnings in astyle scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 4, 2018
1 parent b65ee54 commit e5e966b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
7 changes: 4 additions & 3 deletions scripts/astyle-all.sh
Expand Up @@ -15,13 +15,14 @@
###########################################################################


PATH=$PATH:$(dirname $0)
PATH=$PATH:$(dirname "$0")

set -e

export elcr="$(tput el)$(tput cr)"
elcr="$(tput el)$(tput cr)"
export elcr

find python src tests -type f -print | while read f; do
find python src tests -type f -print | while read -r f; do
if [ -f "$f.astyle" ]; then
# reformat backup
cp "$f.astyle" "$f"
Expand Down
28 changes: 14 additions & 14 deletions scripts/astyle.sh
Expand Up @@ -22,13 +22,13 @@ fi

min_version="3"
astyle_version_check() {
[ $(printf "$($1 --version 2>&1 | cut -d ' ' -f4)\n$min_version" | sort -${SV} | head -n1) = "$min_version" ]
[ $(printf "$($1 --version 2>&1 | cut -d ' ' -f4)\\n$min_version" | sort -${SV} | head -n1) = "$min_version" ]
}

for ASTYLE in ${QGISSTYLE} $(dirname $0)/qgisstyle $(dirname $0)/RelWithDebInfo/qgisstyle astyle
for ASTYLE in ${QGISSTYLE} $(dirname "$0")/qgisstyle $(dirname "$0")/RelWithDebInfo/qgisstyle astyle
do
if type -p $ASTYLE >/dev/null; then
if astyle_version_check $ASTYLE; then
if type -p "$ASTYLE" >/dev/null; then
if astyle_version_check "$ASTYLE"; then
break
fi
fi
Expand All @@ -43,13 +43,13 @@ fi
if type -p tput >/dev/null; then
elcr="$ASTYLEPROGRESS$(tput el)$(tput cr)"
else
elcr="$ASTYLEPROGRESS \r"
elcr="$ASTYLEPROGRESS \\r"
fi

if ! type -p flip >/dev/null; then
if type -p dos2unix >/dev/null; then
flip() {
dos2unix -k $2
dos2unix -k "$2"
}
else
echo "flip not found" >&2
Expand All @@ -66,9 +66,9 @@ if ! type -p autopep8 >/dev/null; then
}
fi

ASTYLEOPTS=$(dirname $0)/astyle.options
ASTYLEOPTS=$(dirname "$0")/astyle.options
if type -p cygpath >/dev/null; then
ASTYLEOPTS="$(cygpath -w $ASTYLEOPTS)"
ASTYLEOPTS="$(cygpath -w "$ASTYLEOPTS")"
fi

set -e
Expand All @@ -85,12 +85,12 @@ astyleit() {

for f in "$@"; do
case "$f" in
src/app/gps/qwtpolar-*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|external/astyle/*|python/ext-libs/*|src/providers/spatialite/qspatialite/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*|python/ext-libs/*|*/ui_*.py|*.astyle|tests/testdata/*|editors/*)
src/app/gps/qwtpolar-*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|external/astyle/*|python/ext-libs/*|src/providers/spatialite/qspatialite/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*|*/ui_*.py|*.astyle|tests/testdata/*|editors/*)
echo -ne "$f skipped $elcr"
continue
;;

*.cpp|*.h|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp)
*.cpp|*.h|*.c|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.hpp)
if [ -x "$f" ]; then
chmod a-x "$f"
fi
Expand All @@ -108,7 +108,7 @@ for f in "$@"; do
;;

*.sip)
cmd="perl -i.prepare -pe 's/[\r\t ]+$//; s#^(\s*)/\*[*!]\s*([^\s*].*)\s*\$#\$1/** \u\$2\n#;'"
cmd="perl -i.prepare -pe 's/[\\r\\t ]+$//; s#^(\\s*)/\\*[*!]\\s*([^\\s*].*)\\s*\$#\$1/** \\u\$2\\n#;'"
;;

*)
Expand All @@ -122,9 +122,9 @@ for f in "$@"; do
continue
fi

if [[ -f $f && $(head -c 3 $f) == $'\xef\xbb\xbf' ]]; then
mv $f $f.bom
tail -c +4 $f.bom > $f
if [[ -f $f && $(head -c 3 "$f") == $'\xef\xbb\xbf' ]]; then
mv "$f" "$f".bom
tail -c +4 "$f".bom > "$f"
echo "removed BOM from $f"
fi

Expand Down

0 comments on commit e5e966b

Please sign in to comment.