aboutsummaryrefslogtreecommitdiff
path: root/bin/cf
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/cf
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/cf')
-rwxr-xr-xbin/cf7
1 files changed, 5 insertions, 2 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"