summaryrefslogtreecommitdiff
path: root/.config/wmii-hg
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-03-21 16:10:08 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-03-21 16:10:08 -0400
commit927aedb7605bba96a6ea2fc707ab026946b4d2b0 (patch)
tree46bfb8d23985fe08bd7793c417321ad27f6fcb8b /.config/wmii-hg
parentb0cdbb3da2c2b36d3c65b00db4eaf5a0d29c2cd6 (diff)
backport changes from my laptop
Diffstat (limited to '.config/wmii-hg')
-rw-r--r--.config/wmii-hg/fixes.sh6
-rw-r--r--.config/wmii-hg/util.sh35
2 files changed, 21 insertions, 20 deletions
diff --git a/.config/wmii-hg/fixes.sh b/.config/wmii-hg/fixes.sh
index aa09157..5858859 100644
--- a/.config/wmii-hg/fixes.sh
+++ b/.config/wmii-hg/fixes.sh
@@ -7,11 +7,11 @@
##
unalias ls &>/dev/null
ls() {
- real_ls="`which ls` -1F"
- [ $# = 0 ] && set -- "`pwd`"
+ local real_ls=("$(which ls)" -1F)
+ [ $# = 0 ] && set -- "$PWD"
f="${1/#${WMII_DIR}/}"
if [ "$f" = "$1" ]; then
- $real_ls "$f"
+ "${real_ls[@]}" "$f"
else
wmiir ls "$f"
fi
diff --git a/.config/wmii-hg/util.sh b/.config/wmii-hg/util.sh
index a4c4bb4..71dbc41 100644
--- a/.config/wmii-hg/util.sh
+++ b/.config/wmii-hg/util.sh
@@ -13,7 +13,7 @@
# It escapes ways to execute code, but not variables.
##
dquote() {
- str=$1
+ local str=$1
str="${str//\\/\\\\}" # backslash
str="${str//\"/\\\"}" # dquote
str="${str//\$(/\\\$(}" # $(...)
@@ -32,8 +32,8 @@ expand_variables() {
}
is_mounted() {
- dir="$(readlink -m $1)"
- mntpnt="$(cut -d' ' -f2 /proc/mounts|grep -- "$dir")"
+ local dir="$(readlink -m $1)"
+ local mntpnt="$(cut -d' ' -f2 /proc/mounts|grep -Fx -- "$dir")"
[[ $dir = "$mntpnt" ]]
return $?
}
@@ -47,8 +47,9 @@ is_mounted() {
# List executables in PATH (PATH is delimited by `:')
##
path_ls() {
- dirs="`echo "$@"|sed 'y/:/ /'`"
- find -L $dirs -maxdepth 1 -type f -executable -printf '%f\n' 2>/dev/null | sort -u
+ local dirs
+ IFS=: dirs=($@)
+ find -L "${dirs[@]}" -maxdepth 1 -type f -executable -printf '%f\n' 2>/dev/null | sort -u
}
##
@@ -56,9 +57,9 @@ path_ls() {
# Find the full path of PROGRAM by searching PATH
##
path_which() {
- mypath=$1
- prog=$2
- which=`which which`
+ local mypath=$1
+ local prog=$2
+ local which=$(which which)
PATH="$mypath" "$which" -- "$prog" 2>/dev/null
}
@@ -71,7 +72,7 @@ path_which() {
# Lists wmii tags
##
lstags() {
- ls $WMII_DIR/tag | sed -e 's@/@@' -e '/^sel$/d'
+ ls "$WMII_DIR/tag" | sed -e 's@/$@@' -e '/^sel$/d'
}
################################################################################
@@ -97,18 +98,18 @@ connected_to_x_server() {
# If SECTION is not given, it reads all doc comments.
##
scansection() {
- file=`conffile config.sh`
- sec=$1
- tmp=`mktemp`
+ local file=$(conffile config.sh)
+ local sec=$1
+ local tmp=$(mktemp --tmpdir wmii-scansecion.XXXXXXXXXX)
# Isolate the sections we want.
if [ -n "$sec" ]; then
# Find the section
- < "$file" sed -n "/^\s*$sec\s*()/,/##\s*End $sec/p" | sed '1d;$d'> $tmp
+ < "$file" sed -n "/^\s*$sec\s*()/,/##\s*End $sec/p" | sed '1d;$d'> "$tmp"
else
# Remove extra lines that mark the end of a section
- < "$file" sed "/\s*}\s*##\s*End\s/d" > $tmp
+ < "$file" sed "/\s*}\s*##\s*End\s/d" > "$tmp"
fi
- < $tmp sed -n '/##/p' | while read; do
+ < "$tmp" sed -n '/##/p' | while read; do
var="$(echo "$REPLY" | sed -nr 's/^\s*(.*)\)\s*##.*/\1/p')"
comment="$(echo "$REPLY" | sed -r 's/.*## ?//')"
if [ -z "$var" ]; then
@@ -117,12 +118,12 @@ scansection() {
printf '\t%s\t%s\n' "$(echo "$var"|expand_variables)" "$comment"
fi
done
- rm $tmp
+ rm -- "$tmp"
}
##
# Usage: conffile FILE
##
conffile() {
- echo "$HOME/.wmii-hg/$@"
+ echo "$HOME/.wmii-hg/$1"
}