aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-05 00:10:59 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-05 00:11:49 +1200
commit1879eebc785de78207dd83386028815b7b99ea18 (patch)
tree67653da81e884cc4200f87e8e074ee036ddf4999 /bin
parentSwitch fnl()/scr() to use mktd(1) (diff)
downloaddotfiles-1879eebc785de78207dd83386028815b7b99ea18.tar.gz
dotfiles-1879eebc785de78207dd83386028815b7b99ea18.zip
Handle different .* expansion in cf(1), dub(1)
OpenBSD seems to omit . and .. from its .* expansion (which actually makes more sense to me), but Bash on Linux does not. This makes the "shift 2" test more explicit.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cf7
-rwxr-xr-xbin/dub4
2 files changed, 8 insertions, 3 deletions
diff --git a/bin/cf b/bin/cf
index 3063d58b..feac0236 100755
--- a/bin/cf
+++ b/bin/cf
@@ -15,9 +15,12 @@ for dir in "${@:-.}" ; do
set -- "$dir"/*
[ -e "$1" ] || shift
- # Add dot files, shift off the "." and ".." entries
+ # Add dot files, shift off the "." and ".." entries (sh(1) implementations
+ # seem to vary on whether they include these)
set -- "$dir"/.* "$@"
- shift 2
+ [ -e "$1" ] || shift
+ [ "$1" = "$dir"/. ] && shift
+ [ "$1" = "$dir"/.. ] && shift
# Print number of parameters
printf '%u\t%s\n' "$#" "$dir"
diff --git a/bin/dub b/bin/dub
index bb3df442..706c95f0 100755
--- a/bin/dub
+++ b/bin/dub
@@ -5,7 +5,9 @@ cd -- "$dir" || exit
set -- *
[ -e "$1" ] || shift
set -- .* "$@"
-shift 2
+[ -e "$1" ] || shift
+[ "$1" = . ] && shift
+[ "$1" = .. ] && shift
du -ks -- "$@" |
sort -k1nr |
sed "$lines"q