[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.
- Re: /dev/fd/62: No such file or directory, Linda Walsh, 2014/04/01
- Re: /dev/fd/62: No such file or directory, Pierre Gaston, 2014/04/02
- Re: /dev/fd/62: No such file or directory,
Greg Wooledge <=
- Re: /dev/fd/62: No such file or directory, Linda Walsh, 2014/04/05
- Re: /dev/fd/62: No such file or directory, Chris Down, 2014/04/05
- Re: /dev/fd/62: No such file or directory, Linda Walsh, 2014/04/05
- Re: /dev/fd/62: No such file or directory, Chris Down, 2014/04/05
- Re: /dev/fd/62: No such file or directory, Pierre Gaston, 2014/04/05
- Re: /dev/fd/62: No such file or directory, Linda Walsh, 2014/04/05