Skip to content

Commit

Permalink
shellcheck: fix info
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Apr 3, 2019
1 parent e9b2405 commit c28a062
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 37 deletions.
6 changes: 4 additions & 2 deletions .travis/after_failure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@

cylc scan -f --color=never

find $HOME/cylc-run -name '*.err' -type f -exec echo '==== {} ====' \; -exec cat '{}' \;
find /tmp/${USER}/cylctb-* -type f -exec echo '==== {} ====' \; -exec cat '{}' \;
find "$HOME/cylc-run" -name '*.err' -type f \
-exec echo '==== {} ====' \; -exec cat '{}' \;
find "/tmp/${USER}/cylctb-"* -type f \
-exec echo '==== {} ====' \; -exec cat '{}' \;
2 changes: 1 addition & 1 deletion bin/cylc-conditions
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ fi
echo
echo "The GNU General Public License v3.0"
echo
cat $CYLC_DIR/COPYING
cat "$CYLC_DIR/COPYING"
echo
14 changes: 7 additions & 7 deletions bin/cylc-graph-diff
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -eu

_clean() {
if [[ -n "${DIFF_FILES:-}" ]]; then
rm -f ${DIFF_FILES:-}
rm -f "${DIFF_FILES[@]:-}"
fi
}

Expand Down Expand Up @@ -55,7 +55,7 @@ for ARG in "$@"; do
else
# A suite - check it's registered.
if ! cylc print --fail "$ARG$" >/dev/null 2>&1; then
echo "Suite not found: "$ARG >&2
echo "Suite not found: $ARG" >&2
exit 1
fi
SUITES="$SUITES $ARG"
Expand All @@ -69,22 +69,22 @@ fi

trap _clean EXIT
trap _clean ERR
DIFF_FILES=""
DIFF_FILES=()
for SUITE in $SUITES; do
FILE=$(mktemp -t "$(tr '/' '.' <<<"${SUITE}").graph.ref.XXXX")
cylc graph --reference "${SUITE}" "$@" >$FILE
DIFF_FILES="$DIFF_FILES $FILE"
cylc graph --reference "${SUITE}" "$@" >"$FILE"
DIFF_FILES+=("$FILE")
done

if $GRAPHICAL_DIFF; then
for DIFFTOOL in xxdiff diffuse kdiff3 kompare gvimdiff2 meld tkdiff; do
if type -P $DIFFTOOL >/dev/null; then
"$DIFFTOOL" $DIFF_FILES
"$DIFFTOOL" "${DIFF_FILES[@]}"
exit 0
fi
done
echo "Error: no graphical diff tool found." >&2
exit 1
fi

$DIFF_CMD $DIFF_FILES
$DIFF_CMD "${DIFF_FILES[@]}"
10 changes: 5 additions & 5 deletions bin/cylc-import-examples
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ if [[ -d $DESTINATION ]]; then
fi

echo " + Copying example suites"
mkdir -p $DESTINATION
cp -r $CYLC_DIR/etc/examples/* $DESTINATION
mkdir -p "$DESTINATION"
cp -r "$CYLC_DIR/etc/examples/*" "$DESTINATION"

echo " + Registering example suites"
cd $DESTINATION
cd "$DESTINATION"
SUITE_RCS=$(find . -name suite.rc | sed -e 's@./@@')
for SUITE_RC in $SUITE_RCS; do
SUITE_DEF_DIR=$(dirname $SUITE_RC)
SUITE_DEF_DIR="$(dirname "$SUITE_RC")"
SUITE_REG_NAME=$BASE_DIR/$SUITE_DEF_DIR
cylc register $SUITE_REG_NAME $SUITE_DEF_DIR
cylc register "$SUITE_REG_NAME" "$SUITE_DEF_DIR"
done

echo "DONE"
7 changes: 4 additions & 3 deletions bin/cylc-jobscript
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if sys.argv[1] in ['-g', '--gedit']:
print glbl_cfg().get(['editors', 'gui'])
elif sys.argv[1] in ['-e', '--edit']:
print glbl_cfg().get(['editors', 'terminal'])
" $1
" "$1"
}

PLAIN=false
Expand All @@ -66,20 +66,21 @@ for arg in "${@}"; do
exit 0
elif [[ "${arg}" == '--edit' ]] || [[ "${arg}" == '--gedit' ]] || \
[[ "${arg}" == '-e' ]] || [[ "${arg}" == '-g' ]]; then
EDITOR_CMD="$(editor ${arg})"
EDITOR_CMD="$(editor "${arg}")"
elif [[ "${arg}" == '--plain' ]]; then
PLAIN=true
else
SUBMIT_ARGS="${SUBMIT_ARGS} ${arg}"
fi
done

if CYLC_SUBMIT_OUT="$(cylc submit --dry-run ${SUBMIT_ARGS})"; then
if CYLC_SUBMIT_OUT="$(cylc submit --dry-run "${SUBMIT_ARGS}")"; then
JOBSCRIPT="$(sed -n 's/^JOB SCRIPT=//p' <<<"${CYLC_SUBMIT_OUT}")"
if ! "${PLAIN}"; then
echo "Task Job Script Generated: ${JOBSCRIPT}" >&2
fi
if [[ -n ${EDITOR_CMD} ]]; then
# shellcheck disable=2086
exec $EDITOR_CMD "${JOBSCRIPT}"
else
exec less "${JOBSCRIPT}"
Expand Down
10 changes: 5 additions & 5 deletions bin/cylc-scp-transfer
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ for T in $SRCE; do
RMACH=${D%:*}
RPATH=${D#*:}

RDIR=$( dirname $RPATH )
RDIR="$( dirname "$RPATH" )"

cylc task message "Creating remote destination directory, $RDIR"
ssh $RMACH mkdir -p $RDIR
ssh "$RMACH" mkdir -p "$RDIR"
else
DIR=$( dirname $D )
DIR="$( dirname "$D" )"
cylc task message "Creating destination directory, $DIR"
mkdir -p $DIR
mkdir -p "$DIR"
fi

COMMAND="scp -B -r $T $D"
echo $COMMAND
echo "$COMMAND"
if $VERBOSE; then
$COMMAND
else
Expand Down
4 changes: 2 additions & 2 deletions etc/dev-bin/make-tarball
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ RELEASE="cylc-${CYLC_VERSION}"
TARBALL=${RELEASE}.tar.gz
BRANCH=$( git rev-parse --abbrev-ref HEAD )

git archive $BRANCH --prefix=$RELEASE/ | gzip > $TARBALL
ls -lh $TARBALL
git archive "$BRANCH" --prefix="$RELEASE/" | gzip > "$TARBALL"
ls -lh "$TARBALL"
4 changes: 2 additions & 2 deletions etc/dev-bin/stop-group-demo.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

for S in $(cylc scan -n groups | awk '{print $1}'); do
echo $S
cylc stop $S
echo "$S"
cylc stop "$S"
done
6 changes: 4 additions & 2 deletions etc/examples/AutoRecover/CleanupTask/bin/fam_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ set -e
sleep 10 # (time to observe the failed tasks in the suite monitor).

# Determine which family member(s) failed, if any
FAILED_TASKS=$(cylc dump $CYLC_SUITE_NAME | grep $CYLC_TASK_CYCLE_TIME | grep failed | sed -e 's/,.*$//')
FAILED_TASKS="$(cylc dump "$CYLC_SUITE_NAME" \
| grep "$CYLC_TASK_CYCLE_TIME" | grep failed | sed -e 's/,.*$//')"

echo "FAILED TASKS:"
for T in $FAILED_TASKS; do
echo -n " $T ..."
if [[ $T == m_* ]]; then
echo "REMOVING family member"
cylc control remove --force $CYLC_SUITE_NAME ${T}.$CYLC_TASK_CYCLE_TIME
cylc control remove \
--force "$CYLC_SUITE_NAME" "${T}.$CYLC_TASK_CYCLE_TIME"
else
echo "NOT REMOVING (not family member)"
fi
Expand Down
6 changes: 3 additions & 3 deletions etc/examples/AutoRecover/EventHook/bin/failhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ sleep 10 # (time to observe failed task in the suite monitor).
# check that the task has in fact failed
TASK_NAME=${TASK%.*}
CYCLE_POINT=${TASK#*.}
RES=$( cylc dump $SUITE | grep $TASK_NAME | grep $CYCLE_POINT )
STATE=$( echo $RES | awk '{print $3}' | sed -e 's/,//' )
RES="$( cylc dump "$SUITE" | grep "$TASK_NAME" | grep "$CYCLE_POINT" )"
STATE="$( echo "$RES" | awk '{print $3}' | sed -e 's/,//' )"
if [[ $STATE != failed ]]; then
echo "HOOK SCRIPT: ERROR: $TASK is not failed: $STATE"
exit 1
Expand All @@ -27,4 +27,4 @@ else
fi

echo "REMOVING FAILED TASK: $TASK"
cylc control remove --force $CYLC_SUITE_NAME $TASK
cylc control remove --force "$CYLC_SUITE_NAME" "$TASK"
4 changes: 2 additions & 2 deletions etc/examples/task-states/bin/change-my-job-sub-method.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ echo "${0}:resetting job batch system with cylc broadcast"

NAME=${TASKID%.*}
CYCLE=${TASKID#*.}
cylc broadcast -n $NAME -p $CYCLE --set '[job]batch system=background' $SUITE

cylc broadcast \
-n "$NAME" -p "$CYCLE" --set '[job]batch system=background' "$SUITE"
2 changes: 1 addition & 1 deletion etc/examples/tutorial/oneoff/retry/bin/HelloWorld.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh

GREETING=${GREETING:-"Goodbye World!"}
echo $GREETING
echo "$GREETING"
4 changes: 2 additions & 2 deletions lib/cylc/job.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cylc__job__main() {
done
# Ensure that the "cylc" command is in PATH. It may not be set up correctly
# in Prelude above, and also not inherited from the job submit environment.
if ! which cylc 1>'/dev/null' 2>&1; then
if ! command -v cylc 1>'/dev/null' 2>&1; then
PATH="${CYLC_DIR}/bin:${PATH}"
fi
# Init-Script
Expand Down Expand Up @@ -147,7 +147,7 @@ cylc__job__main() {
# Send task succeeded message
wait "${CYLC_TASK_MESSAGE_STARTED_PID}" 2>'/dev/null' || true
cylc message -- "${CYLC_SUITE_NAME}" "${CYLC_TASK_JOB}" 'succeeded' || true
trap '' ${CYLC_VACATION_SIGNALS:-} ${CYLC_FAIL_SIGNALS}
trap '' "${CYLC_VACATION_SIGNALS:-}" "${CYLC_FAIL_SIGNALS}"
# Execute success exit script
cylc__job__run_inst_func 'exit_script'
exit 0
Expand Down

0 comments on commit c28a062

Please sign in to comment.