Commits

Jason Ryan committed 686b5e7

Fixing quoting in [[, mostly

Comments (0)

Files changed (16)

Scripts/aurood.py

 #!/usr/bin/python
+# find out-of-date AUR packages
 # by: Florian Bruhin (The Compiler) <aurood@the-compiler.org>
 # I hereby place this code in the public domain.
 

Scripts/brightness

 
 notify() {
   bright=$(</sys/class/backlight/acpi_video0/actual_brightness)
-  if [[ "$bright" -eq 95 ]]; then
-      score="100"
-  else score="$(( $bright * 100 / 95 ))"
+  if (( "$bright" = 95 )); then
+    score="100"
+  else 
+    score="$(( $bright * 100 / 95 ))"
   fi
   printf '%s\n' "Backlight set to ${score}%" | dzen2 -p 3
 }
 cd "$builddir" && "${EDITOR:-vi}" PKGBUILD
 makepkg -si && cd - &>/dev/null
 
-    read -p "Remove Build directory? [Y/n]? " yn
-    if [ "$yn" = y ]; then
-        printf "\n%s\n" "Removing build directory..."
-        rm -rf "$builddir"
-    else
-        printf "%s\n" "Build completed."
-    fi
+read -p "Remove Build directory? [Y/n]? " yn
+if [ "$yn" = y ]; then
+    printf "\n%s\n" "Removing build directory..."
+    rm -rf "$builddir"
+else
+    printf "%s\n" "Build completed."
+fi
 dir="$HOME/Sites/Miromiro/Blog-images"
 url=$(find "$dir" -name *"${image}*")
 
-if [[ -n "$url" ]]; then
+if [[ -n $url ]]; then
 	stub="${url##*/}"
 	printf '%s' "http://miromiro.com/Blog-images/${stub}"
 else
 print_modules() {
   number="${#moduledb[@]}"
   for module in "${!moduledb[@]}"; do
-    if [[ $op == "load" ]]; then
+    if [[ $op = load ]]; then
       sudo modprobe -a "$module"
     fi
   done
 read -r run < <(printf '%s\n' "${most_used[@]}" | $dmenucmd)
 read -r -d '\n' -a top_100 < <(head -n 100 "$cache")
 
-if [[ -n "$run" ]]; then
+if [[ -n $run ]]; then
   $run &&
   printf "%s\n" "$run" "${top_100[@]}" > "$cache"
 fi
 # http://stackoverflow.com/questions/11818408/convert-all-file-extensions-to-lower-case
 
 while read f; do
-    if [[ "$f" = *.* ]]; then
+    if [[ $f = *.* ]]; then
         # Extract the basename
         b="${f%.*}"
 
         # Note: this only works in recent versions of Bash
         l="${x,,}"
 
-        if [[ "$x" != "$l" ]]; then
+        if [[ $x != $l ]]; then
             mv "$f" "$b.$l"
         fi
     else

Scripts/new_kernel

 red="$(tput bold; tput setaf 1)"
 end="$(tput sgr0)"
 
-if [[ $# != 1 ]]; then
+if (( $# != 1 )); then
 	printf '%s\n' "Usage: "${0##*/}" 3.10.8"
 	exit 1
 fi
 printf '%s\n' "Package version updated to ${ylw}$newvers${end}"
 
 # check for .0 release
-if [[ "$vers" =~ ^[0-9].[0-9]{1,2}$ ]]; then
+if [[ $vers =~ ^[0-9].[0-9]{1,2}$ ]]; then
     upvers="${newvers}"
 
     # don't patch .0 releases
     upvers="${newvers%.*}"
 fi
 
-if [[ "$srcvers" != "${upvers}" ]]; then
+if [[ $srcvers != $upvers ]]; then
     sed -i "s:_srcname=linux-[0-9].*:_srcname=linux-${upvers}:" PKGBUILD
     printf '%s\n' "Source name updated to ${cyn}${upvers}"
 fi
 printf '%s\n' "${cyn}Updating checksums…${end}"
 /usr/bin/updpkgsums
 
-if [[ $? -eq 0 ]]; then
+if (( $? = 0 )); then
 	printf '%s\n' "${cyn}Starting build…${end}"
 	/usr/bin/time /usr/bin/makepkg -i
 else
 
 [[ ${PWD##*/} == "octopress" ]] || exit 1
 
-if [[ $# == 1 ]]; then
+if (( $# = 1 )); then
 	find source/_posts/ -name "*$1*" -exec vim {} \;
 else
 	printf '%s\n' "Which post?" && exit 1

Scripts/proc-check

 
 for app in "${list[@]}"; do
     check=$(ps -C "$app" -opid=)
-    if [[ -z "$check" ]]; then
+    if [[ -z $check ]]; then
         case "$app" in
          highlights) $HOME/Scripts/highlights &
                     ;;
 
 imlibsetroot --store $XDG_CONFIG_HOME/background."$file" -s "$xres" "$1"
 
-[[ -z "$extn" ]] && sed -i "${line}s:\(jpg\|png\|gif\):${file}:" $HOME/.xinitrc
+[[ -z $extn ]] && sed -i "${line}s:\(jpg\|png\|gif\):${file}:" $HOME/.xinitrc
 
 	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}"
 files(){
   pass
   local url="${url}${secret}"
-  [[ -n "$subdir" ]] && url="${url}&path=${subdir}"
+  [[ -n $subdir ]] && url="${url}&path=${subdir}"
   # reload for new data
   local json=$(curl -s -n "$url")
   local opts=(-a -e name -u -pe state -u)
     read -r name
     read -r state
   }; do
-    if [[ "$state" != deleted ]]; then
+    if [[ $state != deleted ]]; then
       printf "%s\n" "$name"
     fi
   done < <(jshon "${opts[@]}" <<< "$json")
 }
 
 folders(){
-  if [[ -n "$dir" ]]; then
+  if [[ -n $dir ]]; then
     pass
     local url="${url}${secret}"
     local json=$(curl -s -n "$url")
   done <"$passfile"
 
   for k in "${!passes[@]}"; do
-    [[ "$dir" = "$k" ]] && secret="&secret=${passes[$k]}"
+    [[ $dir = $k ]] && secret="&secret=${passes[$k]}"
   done
 }
 
 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 ;;
 new="tmux -f $HOME/.tmux/conf new -s secured"
 old="tmux attach -t secured -d"
 
-if [[ -z "$SSH_AUTH_SOCK" ]]; then
+if [[ -z $SSH_AUTH_SOCK ]]; then
     eval $(ssh-agent)
     trap "kill $SSH_AGENT_PID" 0
 fi
 
-if [[ -z "$PID" ]]; then
+if [[ -z $PID ]]; then
     urxvtc -title "tmux" -e sh -c "${new}"
 else
     urxvtc -title "tmux" -e sh -c "${old}"
     printf '%s\n' "Volume set to ${vol}" | dzen2 -p 3
 }
 
-if [[ "$1" = up ]]; then
+if [[ $1 = up ]]; then
     up && notify
-elif [[ "$1" = down ]]; then
+elif [[ $1 = down ]]; then
     down && notify
 fi