scripts

My personal collection of scripts
git clone git://src.gearsix.net/scripts
Log | Files | Refs | Atom | README | LICENSE

commit 75ddbd18f22ee11f7a0d1260e6c8221e8a857485
parent 109830edc83789d98c1795fd73b4126284cb09a5
Author: gearsix <gearsix@tuta.io>
Date:   Fri, 23 Sep 2022 13:36:45 +0100

added "tutanota-update.sh"; moved any->src/, nix->src/posix, win->src/windows

Diffstat:
ATODO | 347+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rany/d2h.py -> src/any/d2h.py | 0
Rany/h2d.py -> src/any/h2d.py | 0
Rany/jiggle.py -> src/any/jiggle.py | 0
Rnix/backup.sh -> src/posix/backup.sh | 0
Rnix/catrm.sh -> src/posix/catrm.sh | 0
Rnix/compress-pdf.sh -> src/posix/compress-pdf.sh | 0
Rnix/depreciated/cpc.sh -> src/posix/depreciated/cpc.sh | 0
Rnix/depreciated/openurl.sh -> src/posix/depreciated/openurl.sh | 0
Rnix/depreciated/strlen.sh -> src/posix/depreciated/strlen.sh | 0
Rnix/depreciated/touchn.sh -> src/posix/depreciated/touchn.sh | 0
Rnix/depreciated/xbright.sh -> src/posix/depreciated/xbright.sh | 0
Rnix/depreciated/xopen.sh -> src/posix/depreciated/xopen.sh | 0
Rnix/flac2mp3.sh -> src/posix/flac2mp3.sh | 0
Rnix/git-cfg.sh -> src/posix/git-cfg.sh | 0
Rnix/git-clone-bulk.sh -> src/posix/git-clone-bulk.sh | 0
Rnix/git-pull-all.sh -> src/posix/git-pull-all.sh | 0
Rnix/gobuild.sh -> src/posix/gobuild.sh | 0
Rnix/grepf.sh -> src/posix/grepf.sh | 0
Rnix/mkdcp.sh -> src/posix/mkdcp.sh | 0
Rnix/mkded.sh -> src/posix/mkded.sh | 0
Rnix/mkdmv.sh -> src/posix/mkdmv.sh | 0
Rnix/mkdtouch.sh -> src/posix/mkdtouch.sh | 0
Rnix/onfilech.sh -> src/posix/onfilech.sh | 0
Rnix/openurl.sh -> src/posix/openurl.sh | 0
Rnix/pomodoro.sh -> src/posix/pomodoro.sh | 0
Rnix/preview-md.sh -> src/posix/preview-md.sh | 0
Rnix/pyserve.sh -> src/posix/pyserve.py | 0
Rnix/pyserve.sh -> src/posix/pyserve.sh | 0
Rnix/randstr.sh -> src/posix/randstr.sh | 0
Rnix/shush.sh -> src/posix/shush.sh | 0
Rnix/strindex.sh -> src/posix/strindex.sh | 0
Asrc/posix/tutanota-update.sh | 28++++++++++++++++++++++++++++
Rnix/unfinished/bulk-rename.sh -> src/posix/unfinished/bulk-rename.sh | 0
Rnix/while-true.sh -> src/posix/while-true.sh | 0
Rwin/random.ps1 -> src/windows/random.ps1 | 0
Rwin/zipto7z.ps1 -> src/windows/zipto7z.ps1 | 0
37 files changed, 375 insertions(+), 0 deletions(-)

diff --git a/TODO b/TODO @@ -0,0 +1,347 @@ + +In src/posix/catrm.sh line 6: +for f in $@; do + ^-- SC2068: Double quote array expansions to avoid re-splitting elements. + + +In src/posix/catrm.sh line 9: + read -p "read remove '$(readlink -f $f)' [y/n/c]? " -n 1 ync + ^--^ SC2162: read without -r will mangle backslashes. + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + read -p "read remove '$(readlink -f "$f")' [y/n/c]? " -n 1 ync + + +In src/posix/catrm.sh line 11: + if [ "$ync" == "y" ]; then rm $f + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + if [ "$ync" == "y" ]; then rm "$f" + + +In src/posix/catrm.sh line 12: + elif [ "$ync" == "c" ]; then cat $f; unset ync + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + elif [ "$ync" == "c" ]; then cat "$f"; unset ync + + +In src/posix/compress-pdf.sh line 7: +if [ -z $1 ] || [ -z $2 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + ^-- SC2086: Double quote to prevent globbing and word splitting. + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +if [ -z "$1" ] || [ -z "$2" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + + +In src/posix/compress-pdf.sh line 18: +if [ -e $2 ]; then out="$2"; fi + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +if [ -e "$2" ]; then out="$2"; fi + + +In src/posix/compress-pdf.sh line 20: +gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=$1 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$out $in + ^-- SC2086: Double quote to prevent globbing and word splitting. + ^--^ SC2086: Double quote to prevent globbing and word splitting. + ^-^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS="$1" -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$out" "$in" + + +In src/posix/flac2mp3.sh line 14: +for file in $1/*.flac; do + ^-- SC2231: Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt . + + +In src/posix/flac2mp3.sh line 15: + ffmpeg -i "$file" -qscale:a 0 "${file[@]/%flac/mp3}" + ^------------------^ SC2039: In POSIX sh, string replacement is undefined. + + +In src/posix/git-clone-bulk.sh line 14: +for repo in $@; do git clone $repo; done + ^-- SC2068: Double quote array expansions to avoid re-splitting elements. + ^---^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +for repo in $@; do git clone "$repo"; done + + +In src/posix/git-pull-all.sh line 13: +git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done + ^--^ SC2162: read without -r will mangle backslashes. + + +In src/posix/gobuild.sh line 19: +for a in ${arch[@]}; do + ^--------^ SC2068: Double quote array expansions to avoid re-splitting elements. + + +In src/posix/gobuild.sh line 20: + for o in ${os[@]}; do + ^------^ SC2068: Double quote array expansions to avoid re-splitting elements. + + +In src/posix/gobuild.sh line 28: + GOARCH=$a GOOS=$o go build -o $name-$a-$o $src + ^---^ SC2086: Double quote to prevent globbing and word splitting. + ^-- SC2086: Double quote to prevent globbing and word splitting. + ^-- SC2086: Double quote to prevent globbing and word splitting. + ^--^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + GOARCH=$a GOOS=$o go build -o "$name"-"$a"-"$o" "$src" + + +In src/posix/grepf.sh line 14: +grep -rnw $1 -e "$2" + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +grep -rnw "$1" -e "$2" + + +In src/posix/mkdcp.sh line 15: +mkdir -p $dir + ^--^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +mkdir -p "$dir" + + +In src/posix/mkdcp.sh line 19: +for file in $@; do + ^-- SC2068: Double quote array expansions to avoid re-splitting elements. + + +In src/posix/mkdcp.sh line 20: + cp -r $file $dir; + ^---^ SC2086: Double quote to prevent globbing and word splitting. + ^--^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + cp -r "$file" "$dir"; + + +In src/posix/mkded.sh line 13: +mkdir -p $1; + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +mkdir -p "$1"; + + +In src/posix/mkded.sh line 14: +cd $1; +^---^ SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +cd "$1" || exit; + + +In src/posix/mkded.sh line 15: +if [ $2 ]; then touch $2; fi + ^-- SC2086: Double quote to prevent globbing and word splitting. + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +if [ "$2" ]; then touch "$2"; fi + + +In src/posix/mkded.sh line 16: +$EDITOR $2; + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +$EDITOR "$2"; + + +In src/posix/mkdmv.sh line 19: +for file in $@; do + ^-- SC2068: Double quote array expansions to avoid re-splitting elements. + + +In src/posix/mkdtouch.sh line 12: +mkdir $1 + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +mkdir "$1" + + +In src/posix/mkdtouch.sh line 14: +touch $@ + ^-- SC2068: Double quote array expansions to avoid re-splitting elements. + + +In src/posix/openurl.sh line 6: +for f in $@; do + ^-- SC2068: Double quote array expansions to avoid re-splitting elements. + + +In src/posix/openurl.sh line 7: + for url in "$(grep -o -E 'https?://[^"]+' $f)"; do + ^-- SC2066: Since you double quoted this, it will not word split, and the loop will only run once. + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + for url in "$(grep -o -E 'https?://[^"]+' "$f")"; do + + +In src/posix/pomodoro.sh line 22: +while [ true ]; do + ^--^ SC2160: Instead of '[ true ]', just use 'true'. + + +In src/posix/pomodoro.sh line 24: + sleep "$WORK" && notify-send -a $NAME "Take a break" $msg + ^--^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + sleep "$WORK" && notify-send -a $NAME "Take a break" "$msg" + + +In src/posix/pomodoro.sh line 28: + sleep "$BREAK" && notify-send -a $NAME "Back to work" $msg + ^--^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + sleep "$BREAK" && notify-send -a $NAME "Back to work" "$msg" + + +In src/posix/preview-md.sh line 21: +if [ -e "$out" ]; then rm -i $out; fi + ^--^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +if [ -e "$out" ]; then rm -i "$out"; fi + + +In src/posix/preview-md.sh line 23: +if [ $? -eq 0 ]; then + ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. + + +In src/posix/preview-md.sh line 25: + if [ ! -z $2 ] && [ "$2" = "--open" ] || [ "$2" = "-o" ]; then + ^-- SC2236: Use -n instead of ! -z. + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + if [ ! -z "$2" ] && [ "$2" = "--open" ] || [ "$2" = "-o" ]; then + + +In src/posix/preview-md.sh line 26: + xdg-open "$out" &>/dev/null + ^---------^ SC2039: In POSIX sh, &> is undefined. + + +In src/posix/pyserve.py line 5: +if [ $1 ]; then dir=$1; fi + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +if [ "$1" ]; then dir=$1; fi + + +In src/posix/pyserve.py line 7: +python3 -m http.server --directory $dir + ^--^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +python3 -m http.server --directory "$dir" + + +In src/posix/pyserve.sh line 5: +if [ $1 ]; then dir=$1; fi + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +if [ "$1" ]; then dir=$1; fi + + +In src/posix/pyserve.sh line 7: +python3 -m http.server --directory $dir + ^--^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +python3 -m http.server --directory "$dir" + + +In src/posix/randstr.sh line 14: +if [ $1 ]; then len=$1; fi + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +if [ "$1" ]; then len=$1; fi + + +In src/posix/randstr.sh line 16: +echo $(cat /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w $len | head -n 1) + ^-- SC2046: Quote this to prevent word splitting. + ^-- SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. + ^----------^ SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead. + ^--^ SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: +echo $(cat /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w "$len" | head -n 1) + + +In src/posix/shush.sh line 13: +for bin in $@; do + ^-- SC2068: Double quote array expansions to avoid re-splitting elements. + + +In src/posix/shush.sh line 14: + $bin &>/dev/null + ^---------^ SC2039: In POSIX sh, &> is undefined. + + +In src/posix/strindex.sh line 19: +if [[ "$1" = "-r" ]]; then # swap arguments (e.g. strindex "cat on mat" "mat") + ^---------------^ SC2039: In POSIX sh, [[ ]] is undefined. + + +In src/posix/strindex.sh line 22: + [[ "$x" = "$1" ]] && echo "-1" || echo "${#x}" + ^---------------^ SC2039: In POSIX sh, [[ ]] is undefined. + + +In src/posix/strindex.sh line 25: + [[ "$x" = "$2" ]] && echo "-1" || echo "${#x}" + ^---------------^ SC2039: In POSIX sh, [[ ]] is undefined. + + +In src/posix/while-true.sh line 16: +while [ true ]; do + ^--^ SC2160: Instead of '[ true ]', just use 'true'. + + +In src/posix/while-true.sh line 20: + if [ $2 ]; then + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + if [ "$2" ]; then + + +In src/posix/while-true.sh line 21: + sleep $2 + ^-- SC2086: Double quote to prevent globbing and word splitting. + +Did you mean: + sleep "$2" + +For more information: + https://www.shellcheck.net/wiki/SC2066 -- Since you double quoted this, it ... + https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ... + https://www.shellcheck.net/wiki/SC2039 -- In POSIX sh, &> is undefined. diff --git a/any/d2h.py b/src/any/d2h.py diff --git a/any/h2d.py b/src/any/h2d.py diff --git a/any/jiggle.py b/src/any/jiggle.py diff --git a/nix/backup.sh b/src/posix/backup.sh diff --git a/nix/catrm.sh b/src/posix/catrm.sh diff --git a/nix/compress-pdf.sh b/src/posix/compress-pdf.sh diff --git a/nix/depreciated/cpc.sh b/src/posix/depreciated/cpc.sh diff --git a/nix/depreciated/openurl.sh b/src/posix/depreciated/openurl.sh diff --git a/nix/depreciated/strlen.sh b/src/posix/depreciated/strlen.sh diff --git a/nix/depreciated/touchn.sh b/src/posix/depreciated/touchn.sh diff --git a/nix/depreciated/xbright.sh b/src/posix/depreciated/xbright.sh diff --git a/nix/depreciated/xopen.sh b/src/posix/depreciated/xopen.sh diff --git a/nix/flac2mp3.sh b/src/posix/flac2mp3.sh diff --git a/nix/git-cfg.sh b/src/posix/git-cfg.sh diff --git a/nix/git-clone-bulk.sh b/src/posix/git-clone-bulk.sh diff --git a/nix/git-pull-all.sh b/src/posix/git-pull-all.sh diff --git a/nix/gobuild.sh b/src/posix/gobuild.sh diff --git a/nix/grepf.sh b/src/posix/grepf.sh diff --git a/nix/mkdcp.sh b/src/posix/mkdcp.sh diff --git a/nix/mkded.sh b/src/posix/mkded.sh diff --git a/nix/mkdmv.sh b/src/posix/mkdmv.sh diff --git a/nix/mkdtouch.sh b/src/posix/mkdtouch.sh diff --git a/nix/onfilech.sh b/src/posix/onfilech.sh diff --git a/nix/openurl.sh b/src/posix/openurl.sh diff --git a/nix/pomodoro.sh b/src/posix/pomodoro.sh diff --git a/nix/preview-md.sh b/src/posix/preview-md.sh diff --git a/nix/pyserve.sh b/src/posix/pyserve.py diff --git a/nix/pyserve.sh b/src/posix/pyserve.sh diff --git a/nix/randstr.sh b/src/posix/randstr.sh diff --git a/nix/shush.sh b/src/posix/shush.sh diff --git a/nix/strindex.sh b/src/posix/strindex.sh diff --git a/src/posix/tutanota-update.sh b/src/posix/tutanota-update.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env sh + +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "tutanota-update [installdir]" + echo "Download & install the latest linux desktop AppImage" + echo "from mail.tutanota.com." + echo "" + echo "Arguments:" + echo "- [installdir] is the directory to move the downloaded" + echo " binary to. Default: '/usr/local/bin'." + exit +fi + +if [ "$(whoami)" != "root" ]; then + echo "root priviledges required" + exit +fi + +INSTALL="/usr/local/bin" +if [ "$1" != "" ]; then INSTALL="$1"; fi +OUTBIN="$INSTALL/tutanota" +DWNBIN="./tutanota-desktop-linux.AppImage" +GETURL="https://mail.tutanota.com/desktop/$DWNBIN" + +echo "fetching latest binary..." +wget --quiet "$GETURL" +install "$DWNBIN" "$OUTBIN" +rm "$DWNBIN" diff --git a/nix/unfinished/bulk-rename.sh b/src/posix/unfinished/bulk-rename.sh diff --git a/nix/while-true.sh b/src/posix/while-true.sh diff --git a/win/random.ps1 b/src/windows/random.ps1 diff --git a/win/zipto7z.ps1 b/src/windows/zipto7z.ps1