tmake scripts more portable (ex. for *ash) - scripts - random scripts (HTM) git clone git://parazyd.org/scripts.git (DIR) Log (DIR) Files (DIR) Refs --- (DIR) commit 63de9db030cedb8585044e8856b03bf5a3e228b4 (DIR) parent d65759220b6b5d3b81f573dbf50f476ad5007069 (HTM) Author: parazyd <parazyd@dyne.org> Date: Sun, 31 Jul 2016 10:11:30 +0200 make scripts more portable (ex. for *ash) Diffstat: M addrepo.sh | 2 +- M autoup | 2 +- M dmenuwindows | 2 +- M genhtpasswd | 2 +- M minimpc | 2 +- M p | 10 +++++----- M skrot | 2 +- M supadd | 8 +++----- M xkcd.py | 4 ++-- 9 files changed, 16 insertions(+), 18 deletions(-) --- (DIR) diff --git a/addrepo.sh b/addrepo.sh t@@ -31,7 +31,7 @@ EOF fi } -if [[ -n $reponame ]] && [[ -n $repodesc ]]; then +if [ -n $reponame ] && [ -n $repodesc ]; then cd $GITOLITE writeconf >> conf/gitolite.conf git commit conf/gitolite.conf -m "added $reponame repository" (DIR) diff --git a/autoup b/autoup t@@ -10,4 +10,4 @@ test -z "$1" && exit 1 || filename=$(basename $1) scp -i "$sshkey" "$1" "${sshuser}@${server}:${webroot}/${webdir}/${filename}" echo "https://$server/$webdir/$filename" | xclip -i echo "https://$server/$webdir/$filename" -rm $1 +#rm $1 (DIR) diff --git a/dmenuwindows b/dmenuwindows t@@ -31,5 +31,5 @@ num=$(wmctrl -l \ | cut -d '-' -f -1 \ ) -[[ -z "$num" ]] && exit +[ -z "$num" ] && exit wmctrl -l | sed -n "$num p" | cut -c -10 | xargs wmctrl -i -a (DIR) diff --git a/genhtpasswd b/genhtpasswd t@@ -7,7 +7,7 @@ user="$1" realm="$2" password="$3" -if ! [[ -n $user ]] || ! [[ -n $realm ]] || ! [[ -n $password ]]; then +if [ -z $user ] || [ -z $realm ] || [ -z $password ]; then echo "usage: `basename $0` [user] [realm] [password]" else echo -n "${user}:${realm}:" \ (DIR) diff --git a/minimpc b/minimpc t@@ -6,7 +6,7 @@ MPDHOST=${MPDHOST:-"/home/parazyd/.config/mpd/mpd.sock"} # MPDHOST=${MPDHOST:-"127.0.0.1 6600"} -if [[ $MPDHOST == /* ]] || [[ $MPDHOST == ~/* ]]; then +if [ $MPDHOST == /* ] || [ $MPDHOST == ~/* ]; then NCARGS="-U" else NCARGS="" (DIR) diff --git a/p b/p t@@ -4,13 +4,13 @@ palemoon=/usr/bin/palemoon profile="$1" ps ax | grep '[p]alemoon' > /dev/null -[[ $? = 0 ]] && { +[ $? = 0 ] && { # one is already running, run next with -no-remote opts=" -no-remote " } case $profile in - obi) $palemoon ${opts} -P def;; - soc) $palemoon ${opts} -P soc;; - profile*) $palemoon -ProfileManager;; - *) $palemoon $*;; + obi) exec $palemoon ${opts} -P def;; + soc) exec $palemoon ${opts} -P soc;; + profile*) exec $palemoon -ProfileManager;; + *) exec $palemoon $*;; esac (DIR) diff --git a/skrot b/skrot t@@ -1,6 +1,6 @@ #!/bin/sh -if [ $1 == "-s" ]; then +if [ "$1" == "-s" ]; then scrot -s '%Y-%m-%d_%H-%M-%S_$wx$h.png' -e 'mv $f ~/screenshots/' else scrot '%Y-%m-%d_%H-%M-%S_$wx$h.png' -e 'mv $f ~/screenshots/' (DIR) diff --git a/supadd b/supadd t@@ -48,19 +48,17 @@ EOF getsha() { shasum=`sha256sum $binpath | awk '{print $1}'` - [[ -n $shasum ]] || exit 1 + [ -n $shasum ] || exit 1 } case $1 in -l) grep -v -i -e '//' -e '^#' $supsrc/allowed.txt ;; *) binpath="$1" bin=`echo $binpath | awk -F"/" '{print $NF}'` - if ! [[ $binpath == /* ]]; then - binpath="$PWD/$bin" - fi + [ $binpath == /* ] || binpath="$PWD/$bin" getsha || exit 1 - if [[ `grep $binpath $supsrc/allowed.txt` ]]; then + if [ `grep $binpath $supsrc/allowed.txt` ]; then grep -v $binpath $supsrc/allowed.txt > /tmp/allowed.txt mv /tmp/allowed.txt $supsrc/allowed.txt fi (DIR) diff --git a/xkcd.py b/xkcd.py t@@ -4,7 +4,7 @@ # random xkcd comic import urllib, json, random -latest = 1700 -num=str(random.randint(1,latest)) +latest = 1710 +num = str(random.randint(1,latest)) info = json.load(urllib.urlopen("http://www.xkcd.com/" + num + "/info.0.json")) print info['img']