Fix remaining shellcheck warnings

This commit is contained in:
François Chavant 2017-12-02 19:38:02 +01:00
parent 31710b7045
commit dd589f180b
6 changed files with 19 additions and 21 deletions

View File

@ -22,15 +22,14 @@
# default style to monokai if none is provided # default style to monokai if none is provided
STYLE=${1:-monokai} STYLE=${1:-monokai}
# format json using jq # format json using jq
FORMATTED_JSON="$(cat "$QUTE_TEXT" | jq '.')" if ! FORMATTED_JSON="$(jq . "$QUTE_TEXT")" || [ -z "$FORMATTED_JSON" ]; then
# if jq command failed or formatted json is empty, assume failure and terminate
if [ $? -ne 0 ] || [ -z "$FORMATTED_JSON" ]; then
echo "Invalid json, aborting..." echo "Invalid json, aborting..."
exit 1 exit 1
fi fi
# calculate the filesize of the json document # calculate the filesize of the json document
# parsing the output of ls should be fine in this case since we set the block size
# shellcheck disable=SC2012
FILE_SIZE=$(ls -s --block-size=1048576 "$QUTE_TEXT" | cut -d' ' -f1) FILE_SIZE=$(ls -s --block-size=1048576 "$QUTE_TEXT" | cut -d' ' -f1)
# use pygments to pretty-up the json (syntax highlight) if file is less than 10MB # use pygments to pretty-up the json (syntax highlight) if file is less than 10MB

View File

@ -64,7 +64,7 @@ die() {
javascript_escape() { javascript_escape() {
# print the first argument in an escaped way, such that it can safely # print the first argument in an escaped way, such that it can safely
# be used within javascripts double quotes # be used within javascripts double quotes
sed "s,[\\\'\"],\\\&,g" <<< "$1" sed "s,[\\\\'\"],\\\\&,g" <<< "$1"
} }
# ======================================================= # # ======================================================= #

View File

@ -25,9 +25,7 @@
[[ $QUTE_MODE == 'hints' ]] && title=$QUTE_SELECTED_TEXT || title=$QUTE_TITLE [[ $QUTE_MODE == 'hints' ]] && title=$QUTE_SELECTED_TEXT || title=$QUTE_TITLE
# try to add the task and grab the output # try to add the task and grab the output
msg="$(task add "$title" "$*" 2>&1)" if msg="$(task add "$title" "$*" 2>&1)"; then
if [[ $? == 0 ]]; then
# annotate the new task with the url, send the output back to the browser # annotate the new task with the url, send the output back to the browser
task +LATEST annotate "$QUTE_URL" task +LATEST annotate "$QUTE_URL"
echo "message-info '$msg'" >> "$QUTE_FIFO" echo "message-info '$msg'" >> "$QUTE_FIFO"

View File

@ -50,7 +50,7 @@ msg() {
MPV_COMMAND=${MPV_COMMAND:-mpv} MPV_COMMAND=${MPV_COMMAND:-mpv}
# Warning: spaces in single flags are not supported # Warning: spaces in single flags are not supported
MPV_FLAGS=${MPV_FLAGS:- --force-window --no-terminal --keep-open=yes --ytdl --ytdl-raw-options=yes-playlist=} MPV_FLAGS=${MPV_FLAGS:- --force-window --no-terminal --keep-open=yes --ytdl --ytdl-raw-options=yes-playlist=}
video_command=( "$MPV_COMMAND" $MPV_FLAGS ) IFS=" " read -r -a video_command <<< "$MPV_COMMAND $MPV_FLAGS"
js() { js() {
cat <<EOF cat <<EOF

View File

@ -15,4 +15,4 @@ case $TESTENV in
;; ;;
esac esac
find . -name *.core -o -name core -exec gdb --batch --quiet -ex "thread apply all bt $full" "$exe" {} \; find . \( -name "*.core" -o -name core \) -exec gdb --batch --quiet -ex "thread apply all bt $full" "$exe" {} \;

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
set -e
# This script downloads the given release from GitHub so we can mirror it on # This script downloads the given release from GitHub so we can mirror it on
# qutebrowser.org. # qutebrowser.org.
@ -11,23 +12,23 @@ if [[ $# != 1 ]]; then
exit 1 exit 1
fi fi
cd "$tmpdir" || exit cd "$tmpdir"
mkdir windows mkdir windows
base="https://github.com/qutebrowser/qutebrowser/releases/download/v$1" base="https://github.com/qutebrowser/qutebrowser/releases/download/v$1"
wget "$base/qutebrowser-$1.tar.gz" || exit 1 wget "$base/qutebrowser-$1.tar.gz"
wget "$base/qutebrowser-$1.tar.gz.asc" || exit 1 wget "$base/qutebrowser-$1.tar.gz.asc"
wget "$base/qutebrowser-$1.dmg" || exit 1 wget "$base/qutebrowser-$1.dmg"
wget "$base/qutebrowser_${1}-1_all.deb" || exit 1 wget "$base/qutebrowser_${1}-1_all.deb"
cd windows || exit cd windows
wget "$base/qutebrowser-${1}-amd64.msi" || exit 1 wget "$base/qutebrowser-${1}-amd64.msi"
wget "$base/qutebrowser-${1}-win32.msi" || exit 1 wget "$base/qutebrowser-${1}-win32.msi"
wget "$base/qutebrowser-${1}-windows-standalone-amd64.zip" || exit 1 wget "$base/qutebrowser-${1}-windows-standalone-amd64.zip"
wget "$base/qutebrowser-${1}-windows-standalone-win32.zip" || exit 1 wget "$base/qutebrowser-${1}-windows-standalone-win32.zip"
dest="/srv/http/qutebrowser/releases/v$1" dest="/srv/http/qutebrowser/releases/v$1"
cd "$oldpwd" || exit cd "$oldpwd"
sudo mv "$tmpdir" "$dest" sudo mv "$tmpdir" "$dest"
sudo chown -R http:http "$dest" sudo chown -R http:http "$dest"