bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: /dev/fd/62: No such file or directory


From: Greg Wooledge
Subject: Re: /dev/fd/62: No such file or directory
Date: Wed, 2 Apr 2014 07:57:05 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Apr 02, 2014 at 07:54:58AM +0300, Pierre Gaston wrote:
> On Wed, Apr 2, 2014 at 6:04 AM, Linda Walsh <bash@tlinx.org> wrote:
> > Well don't know if it circumvents the /fd/62 prob
> > yet (got a few places more to check & convert),
> > but this seems to work for checking if a file
> > or dir is empty:
> >
> > function empty {
> >   [[ $# -lt 1 ]] && return -1
> >   [[ -f $1 && ! -s $1 ]] && return 0
> >   [[ -d $1 ]] && {
> >     readarray entries<<<"$(cd "$1" && printf "%s\n" * 2>/dev/null)"
> >     ((${#entries[@]} < 3)) && return 0
> >   }
> >   return 1
> > }

That's unnecessarily complex.

> why not simply: entries=("$1"/*) ?

You need to activate nullglob and dotglob first, but yes, that would be
the way I'd recommend.  That's what we use in
http://mywiki.wooledge.org/BashFAQ/004 as well.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]