Skip to content

Commit

Permalink
Fix shellcheck warnings and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fmarier committed Sep 5, 2015
1 parent 95a9315 commit 3908576
Show file tree
Hide file tree
Showing 28 changed files with 103 additions and 99 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
@echo Running shellcheck...
@shellcheck --exclude SC1071 --exclude SC2096 [a-z]*
#@echo Running bashate...
#@bashate [a-z]*
1 change: 1 addition & 0 deletions b2g
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ if [ "z$1" != "z" ] ; then
RUNAPP="--runapp $1"
fi

# shellcheck disable=SC2086
/home/francois/devel/build_central_b2g/dist/bin/b2g -profile /home/francois/devel/gaia/profile -jsconsole $RUNAPP
5 changes: 3 additions & 2 deletions b2g-build
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
CPU_GOVERNOR=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`
CPU_GOVERNOR=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
if [ "$CPU_GOVERNOR" != "performance" ] ; then
echo "WARNING: your main CPU is set to the $CPU_GOVERNOR governor, this may take a while."
fi

pushd ~/devel/mozilla-central
export MOZCONFIG=`pwd`/.mozconfig-b2g
MOZCONFIG=$(pwd)/.mozconfig-b2g
export MOZCONFIG
./mach build
popd
1 change: 1 addition & 0 deletions cfx-nightly-run
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
# cfs-nightly-run
# cfs-nightly-run --e10s

# shellcheck disable=SC2048,SC2086
cfx run -b /home/francois/devel/mozilla-central/obj-x86_64-unknown-linux-gnu/dist/bin/firefox $*
4 changes: 2 additions & 2 deletions compile_kernel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ ! -r .config ] ; then
exit 1
fi

VERSION=`git log --oneline | head | cut -d' ' -f2,3 | grep "^Linux" | head -1 | cut -d' ' -f2`
VERSION=$(git log --oneline | head | cut -d' ' -f2,3 | grep "^Linux" | head -1 | cut -d' ' -f2)

if [ "z$VERSION" = "z" ] ; then
echo "Could not extract kernel version from the git log."
Expand All @@ -33,5 +33,5 @@ wait $BACKGROUND_BUILD || exit 1

# Install the package
sudo mount -o remount,exec /dev/mapper/ctmp
sudo dpkg -i ../linux-image-$VERSION-grsec+_1.0+custom_*.deb
sudo dpkg -i "../linux-image-$VERSION-grsec+_1.0+custom_"*.deb
sudo mount -o remount /dev/mapper/ctmp
2 changes: 1 addition & 1 deletion conky-i3bar
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
echo '{ "version": 1 }'
echo '['
echo '[],'
exec conky -c $HOME/.conkyrc
exec conky -c "$HOME/.conkyrc"
15 changes: 0 additions & 15 deletions daap-download

This file was deleted.

10 changes: 5 additions & 5 deletions debian-release-hints
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
# Download the latest hint files for the upcoming Debian release

OUTFILE='debian-release.hints'
TMPFILE="`mktemp`"
touch $TMPFILE
TMPFILE="$(mktemp)"
touch "$TMPFILE"

for f in aba adeodato he joeyh luk madcoder neilm pkem rmurray vorlon zobel freeze freeze-exception ftpteam
do
curl --silent --show-error --compressed http://release.debian.org/testing/hints/$f >> $TMPFILE
curl --silent --show-error --compressed "http://release.debian.org/testing/hints/$f" >> "$TMPFILE"
done

if [ ! -e $OUTFILE ]
if [ ! -e "$OUTFILE" ]
then
mv $TMPFILE $OUTFILE
mv "$TMPFILE" "$OUTFILE"
exit 0
else
echo "$OUTFILE already exists."
Expand Down
2 changes: 1 addition & 1 deletion firefoxvaccuum
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ killall firefox
killall xulrunner-stub
killall firefox-bin
killall plugin-container
find $HOME/.mozilla/ \( -name "*.sqlite" \) -exec sqlite3 {} "vacuum" \;
find "$HOME/.mozilla/" \( -name "*.sqlite" \) -exec sqlite3 {} "vacuum" \;
8 changes: 5 additions & 3 deletions fx-build
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
# fx-build -v see the full gcc command line
# fx-build browser/components/preferences only build a portion of the code

OLD_CPU_GOVERNOR=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`
OLD_CPU_GOVERNOR="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)"
if [ "$OLD_CPU_GOVERNOR" != "performance" ] ; then
echo "WARNING: your main CPU is set to the $OLD_CPU_GOVERNOR governor, changing to the performance one."
sudo cpufreq performance
fi

pushd ~/devel/mozilla-central
export MOZCONFIG=`pwd`/.mozconfig-desktop
MOZCONFIG="$(pwd)/.mozconfig-desktop"
export MOZCONFIG
# shellcheck disable=SC2048,SC2086
./mach --log-no-times build $*
RET=$?
popd

if [ "$OLD_CPU_GOVERNOR" != "performance" ] ; then
echo "Changing your CPU back to the $OLD_CPU_GOVERNOR governor."
sudo cpufreq $OLD_CPU_GOVERNOR
sudo cpufreq "$OLD_CPU_GOVERNOR"
fi

exit $RET
6 changes: 3 additions & 3 deletions git-apply-grsec
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ elif [ ! -r ".config" ] ; then
fi

# Remove the last patch if necessary
NEEDS_RESET="`git log --oneline | head -1 | grep 'Applied grsecurity' >/dev/null && echo yes`"
NEEDS_RESET="$(git log --oneline | head -1 | grep 'Applied grsecurity' >/dev/null && echo yes)"
if [ "z$NEEDS_RESET" = "zyes" ] ; then
git reset --hard HEAD^
git clean -f
git clean -d -f
fi

fakeroot make-kpkg clean
(patch -p1 < $1) || (echo "Failed to apply patch" && exit 1)
(patch -p1 < "$1") || (echo "Failed to apply patch" && exit 1)
git add grsecurity/ include/linux/gr* localversion-grsec tools/
git add include/linux/netfilter net/netfilter scripts/gcc-plugin.sh
git add include/trace/events arch/x86/kernel
git commit -a -m "Applied `basename $1`"
git commit -a -m "Applied $(basename "$1")"
5 changes: 3 additions & 2 deletions i3-battery-indicator
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
SLEEP_TIME=5 # Default time between checks.
SAFE_PERCENT=30 # Still safe at this level.
DANGER_PERCENT=15 # Warn when battery at this level.
CRITICAL_PERCENT=5 # Hibernate when battery at this level.

NAGBAR_PID=0
export DISPLAY=:0.0
Expand All @@ -19,6 +18,7 @@ function launchNagBar
function killNagBar
{
if [[ $NAGBAR_PID -ne 0 ]]; then
# shellcheck disable=SC2009
ps -p $NAGBAR_PID | grep "i3-nagbar"
if [[ $? -eq 0 ]]; then
kill $NAGBAR_PID
Expand All @@ -27,11 +27,12 @@ function killNagBar
fi
}

# shellcheck disable=SC2078
while [ true ]; do

killNagBar

if [[ -n $(acpi -b | grep -i discharging) ]]; then
if acpi -b | grep -q -i discharging ; then
rem_bat=$(acpi -b | grep -Eo "[0-9]+%" | grep -Eo "[0-9]+")

if [[ $rem_bat -gt $SAFE_PERCENT ]]; then
Expand Down
18 changes: 9 additions & 9 deletions lv
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
# Usage:
# lv work_report03

filename=`basename $1 .tex`
filename="$(basename "$1" .tex)"

function cleanup {
mv -f $filename.ps $filename.aux $filename.bbl $filename.blg $filename.log $filename.dvi $filename.lof $filename.toc texput.log /tmp 2> /dev/null
echo `untex -a -e -m -o $filename.tex | wc -w` words
mv -f "$filename.ps" "$filename.aux" "$filename.bbl" "$filename.blg" "$filename.log" "$filename.dvi" "$filename.lof" "$filename.toc" texput.log /tmp 2> /dev/null
echo "$(untex -a -e -m -o "$filename.tex" | wc -w)" words
}

function terminate {
cleanup
exit 1
}

latex $filename.tex || terminate
bibtex $filename
latex $filename.tex || terminate # Second pass for references and table of contents
latex $filename.tex || terminate # Third pass for bibliography
latex "$filename.tex" || terminate
bibtex "$filename"
latex "$filename.tex" || terminate # Second pass for references and table of contents
latex "$filename.tex" || terminate # Third pass for bibliography

dvipdfm -z 9 -p `cat /etc/papersize` $filename.dvi
evince $filename.pdf &
dvipdfm -z 9 -p "$(cat /etc/papersize)" "$filename.dvi"
evince "$filename.pdf" &
cleanup
30 changes: 15 additions & 15 deletions mail_fingerprints
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#!/bin/sh

POP_FILE=`mktemp`
IMAP1_FILE=`mktemp`
IMAP2_FILE=`mktemp`
SMTP1_FILE=`mktemp`
SMTP2_FILE=`mktemp`
POP_FILE="$(mktemp)"
IMAP1_FILE="$(mktemp)"
IMAP2_FILE="$(mktemp)"
SMTP1_FILE="$(mktemp)"
SMTP2_FILE="$(mktemp)"

echo "" | openssl s_client -connect pop.gmail.com:995 -showcerts > $POP_FILE 2> /dev/null
echo "" | openssl s_client -connect imap.gmail.com:993 -showcerts > $IMAP1_FILE 2> /dev/null
echo "" | openssl s_client -connect imap.kolabnow.com:993 -showcerts > $IMAP2_FILE 2> /dev/null
echo "" | openssl s_client -connect smtp.gmail.com:587 -starttls smtp -showcerts > $SMTP1_FILE 2> /dev/null
echo "" | openssl s_client -connect smtp.kolabnow.com:587 -starttls smtp -showcerts > $SMTP2_FILE 2> /dev/null
echo "" | openssl s_client -connect pop.gmail.com:995 -showcerts > "$POP_FILE" 2> /dev/null
echo "" | openssl s_client -connect imap.gmail.com:993 -showcerts > "$IMAP1_FILE" 2> /dev/null
echo "" | openssl s_client -connect imap.kolabnow.com:993 -showcerts > "$IMAP2_FILE" 2> /dev/null
echo "" | openssl s_client -connect smtp.gmail.com:587 -starttls smtp -showcerts > "$SMTP1_FILE" 2> /dev/null
echo "" | openssl s_client -connect smtp.kolabnow.com:587 -starttls smtp -showcerts > "$SMTP2_FILE" 2> /dev/null

echo "pop.gmail.com:"
openssl x509 -fingerprint -md5 -noout -in $POP_FILE && rm $POP_FILE
openssl x509 -fingerprint -md5 -noout -in "$POP_FILE" && rm "$POP_FILE"

echo
echo "imap.gmail.com:"
openssl x509 -fingerprint -md5 -noout -in $IMAP1_FILE && rm $IMAP1_FILE
openssl x509 -fingerprint -md5 -noout -in "$IMAP1_FILE" && rm "$IMAP1_FILE"

echo
echo "imap.kolabnow.com:"
openssl x509 -fingerprint -md5 -noout -in $IMAP2_FILE && rm $IMAP2_FILE
openssl x509 -fingerprint -md5 -noout -in "$IMAP2_FILE" && rm "$IMAP2_FILE"

echo
echo "smtp.gmail.com:"
openssl x509 -fingerprint -sha256 -noout -in $SMTP1_FILE && rm $SMTP1_FILE
openssl x509 -fingerprint -sha256 -noout -in "$SMTP1_FILE" && rm "$SMTP1_FILE"

echo
echo "smtp.kolabnow.com:"
openssl x509 -fingerprint -sha256 -noout -in $SMTP2_FILE && rm $SMTP2_FILE
openssl x509 -fingerprint -sha256 -noout -in "$SMTP2_FILE" && rm "$SMTP2_FILE"
8 changes: 4 additions & 4 deletions mcal
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ fi
PSFILE="$(mktemp calendar-XXXX.ps)"
PDFFILE="$(mktemp -p. calendar-XXXX.pdf)"

pcal -F 1 -m -o $PSFILE $MONTH $YEAR
ps2pdf $PSFILE $PDFFILE
rm -f $PSFILE
pcal -F 1 -m -o "$PSFILE" "$MONTH" "$YEAR"
ps2pdf "$PSFILE" "$PDFFILE"
rm -f "$PSFILE"

echo Generated $PDFFILE
echo Generated "$PDFFILE"
2 changes: 1 addition & 1 deletion pdf2txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
/usr/bin/pdftotext -enc UTF-8 -eol unix $1 -
/usr/bin/pdftotext -enc UTF-8 -eol unix "$1" -
2 changes: 2 additions & 0 deletions pdfmerge
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#!/bin/sh
# shellcheck disable=SC2048,SC2086
gs -sDEVICE=pdfwrite -sOutputFile=merged.pdf -q -dNOPAUSE $* quit.ps
2 changes: 1 addition & 1 deletion pngstripper
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

if [ "z$1" = "z" ] ; then
echo "Usage: `basename $0` file1.png"
echo "Usage: $(basename "$0") file1.png"
exit 1
fi

Expand Down
22 changes: 12 additions & 10 deletions remote_screenshot
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@
# TODO: make fwknop optional

if [ "z$1" = "z" ]; then
echo "Usage: `basename $0` hostname"
echo "Usage: $(basename "$0") hostname"
exit 1
fi

TARGET_HOST="$1"
TARGET_DISPLAY=":0.0"

# Take the screenshot
#fwknop --quiet --Last-host $TARGET_HOST
SCREENSHOT_FILE="`ssh $TARGET_HOST mktemp screenshotXXXXXXXX`.jpg"
#fwknop --quiet --Last-host "$TARGET_HOST"
SCREENSHOT_FILE="$(ssh "$TARGET_HOST" mktemp screenshotXXXXXXXX).jpg"
stty -echo
ssh $TARGET_HOST rm `basename $SCREENSHOT_FILE .jpg` \&\& sudo -S DISPLAY=$TARGET_DISPLAY import -window root $SCREENSHOT_FILE || (stty echo && exit 2)
# shellcheck disable=SC2029
ssh "$TARGET_HOST" rm "$(basename "$SCREENSHOT_FILE" .jpg)" \&\& sudo -S DISPLAY="$TARGET_DISPLAY" import -window root "$SCREENSHOT_FILE" || (stty echo && exit 2)
echo
stty echo

# Copy the screenshot over
OUTPUT_FILE="`mktemp ./screenshotXXXXXXXX`.jpg"
rm `basename $OUTPUT_FILE .jpg`
#fwknop --quiet --Last-host $TARGET_HOST
scp $TARGET_HOST:$SCREENSHOT_FILE $OUTPUT_FILE
OUTPUT_FILE="$(mktemp ./screenshotXXXXXXXX).jpg"
rm "$(basename "$OUTPUT_FILE" .jpg)"
#fwknop --quiet --Last-host "$TARGET_HOST"
scp "$TARGET_HOST":"$SCREENSHOT_FILE" "$OUTPUT_FILE"

# Delete screenshot from remote server
#fwknop --quiet --Last-host $TARGET_HOST
ssh $TARGET_HOST sudo rm $SCREENSHOT_FILE
#fwknop --quiet --Last-host "$TARGET_HOST"
# shellcheck disable=SC2029
ssh "$TARGET_HOST" sudo rm "$SCREENSHOT_FILE"
1 change: 1 addition & 0 deletions safemplayer
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
#
# Run mplayer with all options that are useful when dealing with broken files

# shellcheck disable=SC2086
mplayer -ao sdl -nocache -nobps -ni -forceidx -mc 0 $1
5 changes: 3 additions & 2 deletions spascp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# NOTE: for the fwknop command to work, you must first configure it in ~/.fwknoprc

# Extract the hostname from an scp destination
hostname="`echo ${!#} | perl -pe 's/^([^@]*\@)?([^:]+):.*$/$2/'`"
hostname="$(echo "${!#}" | perl -pe 's/^([^@]*\@)?([^:]+):.*$/$2/')"

fwknop -n $hostname && scp $*
# shellcheck disable=SC2048,SC2086
fwknop -n "$hostname" && scp $*
10 changes: 6 additions & 4 deletions spassh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
# NOTE: for the fwknop command to work, you must first configure it in ~/.fwknoprc

# Extract the hostname from an scp destination
hostname="`echo ${!#} | perl -pe 's/^([^@]*\@)?(.*)$/$2/'`"
hostname="$(echo "${!#}" | perl -pe 's/^([^@]*\@)?(.*)$/$2/')"

version=`fwknop -V | head -1 | cut -d'v' -f2 | cut -d'.' -f1`
version="$(fwknop -V | head -1 | cut -d'v' -f2 | cut -d'.' -f1)"

export http_proxy=""
if [ "$version" = "1" ] ; then
fwknop --quiet --Last-host $hostname && ssh $*
# shellcheck disable=SC2048,SC2086
fwknop --quiet --Last-host "$hostname" && ssh $*
else
fwknop -n $hostname && ssh $*
# shellcheck disable=SC2048,SC2086
fwknop -n "$hostname" && ssh $*
fi
8 changes: 4 additions & 4 deletions startup
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ dnssec-trigger-panel &
redshift-gtk -l manual &

# Vacuuming SQLite databases
find $HOME/.mozilla/ \( -name "*.sqlite" \) -execdir sqlite3 {} "vacuum" \;
find "$HOME/.mozilla/" \( -name "*.sqlite" \) -execdir sqlite3 {} "vacuum" \;

# Cleanup unnecessary files
rm -rf $HOME/.cache/chromium
rm -rf $HOME/.thumbnails
rm -rf $HOME/.local/share/Trash
rm -rf "$HOME/.cache/chromium"
rm -rf "$HOME/.thumbnails"
rm -rf "$HOME/.local/share/Trash"

# Graphical programs
emacs --daemon
Expand Down
Loading

0 comments on commit 3908576

Please sign in to comment.