Greg Wooledge wrote:
On Wed, Apr 02, 2014 at 07:54:58AM +0300, Pierre Gaston wrote:
[[ -d $1 ]] && {
readarray entries<<<"$(cd "$1" && printf "%s\n" * 2>/dev/null)"
((${#entries[@]} < 3)) && return 0
That's unnecessarily complex.
why not simply: entries=("$1"/*) ?
----
Indeed -- I just got around to changing this (been an odd week)...
combining it with a hint from greg:
You need to activate nullglob and dotglob first, but yes, that would be
the way I'd recommend.
----
dotglob is already activated, nullglob is not. I thought about it
if nullblob is unset, then I'll always have 1 element in the array --
so I don't have to worry about coding for an 'unset' value.
So all I need do is test the first entry:
local -a entries=("$1"/*)
[[ ${entries[0]} == $1/* ]] && return 0
--- the $1 doesn't need quotes in [[]] and '*' won't expand or
am missing something? Thanks for the tip Pierre, I often
don't see forests because of all the trees...