On Sat, Apr 5, 2014 at 1:46 PM, Linda Walsh <b...@tlinx.org> wrote: > > > Chris Down wrote: > >> Linda Walsh writes: >> >>> 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... >>> >> >> The RHS of [[ has pattern matching applied on unquoted parts, so yes, >> you probably want quotes around $1. >> > ---- > Pattern matching? Why doesn't '*' match anything then? > > Do you mean pathname expansion? or are you thinking of the =~ > operator? I.e. where would it match a pattern? It can't match > in the current directory, since it just failed a pathname > expansion in the line before. But for a regex, I thought you > needed '=~' ?? > > * matches everything and nothing, so you need to quote the whole thing
$ [[ foo == * ]] && echo true true your test will also fail if there is one file named "*" it' better to just [[ -e ${entries[0]} ]]