Commits

Jason Ryan committed ab63b01

Syntax cleanup

Comments (0)

Files changed (13)

 basedir="/home/jason/Build/abs"
 searchdirs=("${basedir}/core" "${basedir}/extra" "${basedir}/community")
 
-[[ $# != 1 ]] && exit 1
+(( $# != 1 )) && exit 1
 
 absversion() {
   # vim is special; yes, this is truly ugly…
-  if [[ "${target#*s/}" == "extra/vim" ]]; then
+  if [[ ${target#*s/} == extra/vim ]]; then
     vim=($(awk '/^_topver/,/^pkgrel/' ${target}/PKGBUILD))
     avers="${vim[0]:8}.${vim[1]:12}-${vim[5]:7}"
   else
       absversion
 
       # synchronize repo
-      if [[ "$avers" < "$rvers" ]]; then
+      if [[ $avers < $rvers ]]; then
         printf "%s\n\n" "Updating ABS $1 package…"
         /usr/bin/abs "${target#*s/}" >/dev/null
         absversion
       printf "%s\n%s\n" "${mag}ABS version${end}" "$avers"
 
       # locally installed?
-      if [[ -n "$ivers" ]]; then
+      if [[ -n $ivers ]]; then
         printf "\n%s\n%s\n" "${cyn}Installed${end}" "$ivers"
       else
         printf "\n%s\n" "${red}${name} not installed…${end}"
 back="$HOME/Centurion/Archer"
 dirs=("$HOME/.config" "$HOME/Scripts" "$HOME/Build/dwm" "$HOME/Build/vimprobable2-git")
 
-if [ -z "$lan" ]; then 
+if [[ -z $lan ]]; then 
     printf "%s\n" "Not on home LAN; exiting…"
     exit 1
 fi
 
-if [[ -d "$back" ]]; then
+if [[ -d $back ]]; then
     printf "%s\n" "Already mounted..."
 else
     sudo mount.nfs 192.168.1.100:/home/jason $HOME/Centurion
 
 
 # if X is running
-if [[ "$DISPLAY" ]]; then
+if [[ $DISPLAY ]]; then
     # check for running wm
     for w in "${wms[@]}"; do
         if pidof "$w" &>/dev/null; then
 orpfile=$(mktemp -t aurphans.XXXXXX)
 
 # remove old files
-[[ ( -e "$aurfile" && -e "$orpfile" ) ]] && rm /tmp/aur{phans,updates}*
+[[ ( -e $aurfile && -e $orpfile ) ]] && rm /tmp/aur{phans,updates}*
 
 # check for updates
 /usr/bin/cower --color=never -u > "$aurfile"
 
 checkbusy() {
   grep "PID" <(lsof +d "$target" &>/dev/null)
-  if [[ $? -eq 0 ]]; then
+  if (( $? == 0 )); then
     printf "%s\n" "${target##*/} busy…"
     exit 1
   fi
 }
 
 exstatus() {
-  if [[ $? -eq 0 ]]; then
+  if (( $? == 0 )); then
     printf "%s\n" "${target##*/} unmounted…"
   else
     printf "%s\n" "Failed to unmount."
 }
 
 # check for multiple devices
-if (( "${#target[@]}" > 1 )); then
+if (( ${#target[@]} > 1 )); then
   PS3="Select your device to unmount: "
   printf "%s\n" "There are ${#target[@]} devices mounted"
   select dev in "${target[@]}"; do
 
 # check for share
 for drive in "${shares[@]}"; do
-  if [[ "$drive" = "${target##*/}" ]]; then
+  if [[ $drive = ${target##*/} ]]; then
     share="$drive"
   fi
 done
 
 # options per filesystem
-if [[ -n "$target" ]]; then
+if [[ -n $target ]]; then
   for drive in "${shares[@]}"; do
-    if [[ "$drive" = "${target##*/}" && "${target##*/}" = Safebox ]]; then
+    if [[ $drive = ${target##*/} && ${target##*/} = Safebox ]]; then
       cmd=$(sudo safebox close)
-    elif [[ "$drive" = "${target##*/}" ]]; then
+    elif [[ $drive = ${target##*/} ]]; then
       cmd=$(sudo umount "$target")
     else
       cmd=$(udiskie-umount -d "$target" &>/dev/null)
 
 mbt(){
     tmp="$(awk '/^MB/ {print +$3}' <(sensors))"
-    if (( "$tmp" < "45" )); then
+    if (( $tmp < 45 )); then
         echo -e "MB \x07$tmp\x01"
     else
         echo -e "\x03MB $tmp\x01"
             END {if (NR==12) print a,b,c,d; else print a,b,c}
         ' <(df -P)) )
     drives="${#hd[@]}"
-    if (( "$drives" > 3 )); then
+    if (( $drives > 3 )); then
         echo -e "\x08${hd[@]:0:3} \x06${hd[@]:3:1}\x01"
     else
         echo -e "\x08${hd[@]}\x01"
     --log-file=Documents/rsync-$(date +%d%m%y).log \
     /home/jason /etc /var/cache/pacman /media/Sentinel/Archer
 
-if [ "$?" -eq 0 ]; then
+if [ $? -eq 0 ]; then
     printf '%s\n' "Synched successfully; now unmounting."
     umount /media/Sentinel
 else
 #!/usr/bin/env bash
 # edit posts in Octopress
 
-[[ "${PWD##*/}" == "octopress" ]] || exit 1
+[[ ${PWD##*/} == octopress ]] || exit 1
 
-if [[ $# == 1 ]]; then
+if (( $# == 1 )); then
 	find source/_posts/ -name "*$1*" -exec "${EDITOR:-vi}" {} \;
 else
 	printf '%s\n' "Which post?" && exit 1
 mountpt=/media/"$cryptdev"
 
 # must be run as root
-if [[ $EUID != 0 ]]; then
+if (( $EUID != 0 )); then
   printf "%s\n" "You must be root to run this."
   exit 1
 fi
 
 # unecrypt and mount container
-if [[ "$1" == "open" ]]; then
+if [[ $1 == open ]]; then
   losetup "$loopdev" "$cryptpath"
   tcplay --map="$cryptdev" --device="$loopdev"
 
 EOF
 
   # mount container
-  [[ -d "$mountpt" ]] || mkdir "$mountpt"
+  [[ -d $mountpt ]] || mkdir "$mountpt"
 
   # mount options
   userid=$(awk -F"[=(]" '{print $2,$4}' <(id "$user"))
   mount -o nosuid,uid="${userid% *}",gid="${userid#* }" /dev/mapper/"$cryptdev" "$mountpt"
 
 # close and clean up…
-elif [[ "$1" == "close" ]]; then
+elif [[ $1 == close ]]; then
   device=$(awk -v dev=$cryptdev -F":" '/dev/ {print $1}' <(losetup -a))
   umount "$mountpt"
   dmsetup remove "$cryptdev" || printf "%s\n" "demapping failed"
 	while true; do
 		read -p "Which archive? " archive
 		# check for an archive number
-		if [[ "$archive" =~ ^[0-9]{6}_[0-9]{2}:[0-9]{2}$ ]]; then
+		if [[ $archive =~ ^[0-9]{6}_[0-9]{2}:[0-9]{2}$ ]]; then
 			case "$opt" in
 				-d) op="${del}${archive}"
 					break
 }
 
 opt="$1"
-[[ -z "$opt" ]] && usage && exit 1
+[[ -z $opt ]] && usage && exit 1
 
 case "$1" in
 	-a) op="${arc}"
 actions=("start" "restart" "stop" "enable" "disable")
  
 for i in "${actions[@]}"; do
-    [[ "$i" = "$arg1" ]] && super="yes"
+    [[ $i = $arg1 ]] && super="yes"
 done
 
 
-if [[ $# -eq 2 ]] && [[ "$super" == "yes" ]]; then 
+if (( $# == 2 )) && [[ $super == yes ]]; then 
     sudo systemctl "$1" "$2".service
 
-elif [[ $# -eq 2 ]] && [[ "$1" == "read" ]]; then
+elif (( $# ===2 )) && [[ $1 == read ]]; then
     less -FX /usr/lib/systemd/system/"$2".service
 
-elif [[ $# -eq 2 ]]; then
+elif (( $# == 2 )); then
     systemctl "$1" "$2".service
 fi
 
-if [[ $# -eq 1 ]]; then
+if (( $# == 1 )); then
 
     case "$1" in
         list) systemctl list-units ;;
     atq | sort -r -k3M -k4
 }
 
-if [[ $# -ge 1 ]]; then
+if (( $# > 1 )); then
     case "$1" in
         -p) print "$2" && exit 0 ;;
         -l) list && exit 0 ;;
 }
 
 case $# in
-    1)  if [[ "$1" =~ "Videos" ]]; then
+    1)  if [[ $1 =~ Videos ]]; then
             xset dpms 0 0 0
             xautolock -disable
             mpv "$1"