Debian Bug report logs - #385069
moreutils: Please add "dirempty" command

version graph

Package: moreutils; Maintainer for moreutils is Nicolas Schier <nicolas@fjasle.eu>; Source for moreutils is src:moreutils (PTS, buildd, popcon).

Reported by: Erich Schubert <erich@debian.org>

Date: Mon, 28 Aug 2006 21:04:00 UTC

Severity: wishlist

Tags: patch

Found in versions moreutils/0.16, moreutils/0.45

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Joey Hess <joeyh@debian.org>:
Bug#385069; Package moreutils. (full text, mbox, link).


Message #3 received at submit@bugs.debian.org (full text, mbox, reply):

From: Erich Schubert <erich@debian.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: moreutils: Please add "dirempty" command
Date: Mon, 28 Aug 2006 22:31:35 +0200
Package: moreutils
Version: 0.16
Severity: wishlist

Hi,
Testing a directory to be empty in bash is hackish, see
http://wooledge.org/mywiki/BashFaq#head-6ec77504553115e8518271d0d319e27148634f19

The cleanest way probably is
if [ -z "$(ls -A "$dir")" ]; then
fi

Maybe we should add a small utility which does test this in a sane way.

if dirempty "$dir"; then
fi

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.17.7
Locale: LANG=de_DE.UTF-8@euro, LC_CTYPE=de_DE.UTF-8@euro (charmap=UTF-8)

Versions of packages moreutils depends on:
ii  libc6                        2.3.6.ds1-4 GNU C Library: Shared libraries
ii  perl                         5.8.8-6.1   Larry Wall's Practical Extraction 

moreutils recommends no packages.

-- no debconf information



Information forwarded to debian-bugs-dist@lists.debian.org, Joey Hess <joeyh@debian.org>:
Bug#385069; Package moreutils. (full text, mbox, link).


Acknowledgement sent to Erich Schubert <erich@debian.org>:
Extra info received and forwarded to list. Copy sent to Joey Hess <joeyh@debian.org>. (full text, mbox, link).


Message #8 received at 385069@bugs.debian.org (full text, mbox, reply):

From: Erich Schubert <erich@debian.org>
To: 385069@bugs.debian.org
Subject: diremtpy or "exists"?
Date: Sat, 02 Sep 2006 03:55:33 +0200
Hi,
A minute ago I didn't need "dirempty", but "exists 'foo/*.bar'"
test -e "foo" works fine if you have the filename. If you have wildcards
it gets a bit more complicated. IMHO it would be good to have a
convenience command for this instead of using some shell magic with test
and ls.

best regards,
Erich Schubert
-- 
     erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C     (o_
             Reality continues to ruin my life --- Calvin              //\
Wende Dein Gesicht der Sonne zu, dann fallen die Schatten hinter Dich. V_/_




Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#385069; Package moreutils. (full text, mbox, link).


Acknowledgement sent to Joey Hess <joeyh@debian.org>:
Extra info received and forwarded to list. (full text, mbox, link).


Message #13 received at 385069@bugs.debian.org (full text, mbox, reply):

From: Joey Hess <joeyh@debian.org>
To: 385069@bugs.debian.org, Erich Schubert <erich@debian.org>
Subject: Re: diremtpy or "exists"?
Date: Thu, 7 Sep 2006 20:43:26 -0400
[Message part 1 (text/plain, inline)]
I think that by generalising beyond dirempty to include exists, you're
getting closer to a generic unix tool.

I worry though that the tool might be test(1). These seem like fairly
good candidates to add to test, especially dirempty.

-- 
see shy jo
[signature.asc (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#385069; Package moreutils. (full text, mbox, link).


Acknowledgement sent to Joey Hess <joeyh@debian.org>:
Extra info received and forwarded to list. (full text, mbox, link).


Message #18 received at 385069@bugs.debian.org (full text, mbox, reply):

From: Joey Hess <joeyh@debian.org>
To: Erich Schubert <erich@debian.org>, 385069@bugs.debian.org
Subject: Re: Bug#385069: diremtpy or "exists"?
Date: Thu, 7 Sep 2006 20:45:27 -0400
[Message part 1 (text/plain, inline)]
Erich Schubert wrote:
> A minute ago I didn't need "dirempty", but "exists 'foo/*.bar'"
> test -e "foo" works fine if you have the filename. If you have wildcards
> it gets a bit more complicated. IMHO it would be good to have a
> convenience command for this instead of using some shell magic with test
> and ls.

Hmm, and dirempty is just ! exists foo/* && ! exists foo/.* , right?

-- 
see shy jo
[signature.asc (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, Joey Hess <joeyh@debian.org>:
Bug#385069; Package moreutils. (full text, mbox, link).


Acknowledgement sent to Erich Schubert <erich@debian.org>:
Extra info received and forwarded to list. Copy sent to Joey Hess <joeyh@debian.org>. (full text, mbox, link).


Message #23 received at 385069@bugs.debian.org (full text, mbox, reply):

From: Erich Schubert <erich@debian.org>
To: Joey Hess <joeyh@debian.org>
Cc: 385069@bugs.debian.org
Subject: Re: Bug#385069: diremtpy or "exists"?
Date: Fri, 08 Sep 2006 03:20:02 +0200
Hi Joey,
> Hmm, and dirempty is just ! exists foo/* && ! exists foo/.* , right?

Maybe "exists -d foo" would be nicer for this.
In many applications, "exists 'foo/*'" would do the job okay enough (if
you don't plan to rm the directory)

best regards,
Erich Schubert
-- 
     erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C    (o_
        To be trusted is a greater complement than to be loved.       //\
 Man kann sich auch in Gesellschaft anderer einsam fühlen. Weizsäcker V_/_




Information forwarded to debian-bugs-dist@lists.debian.org, Joey Hess <joeyh@debian.org>:
Bug#385069; Package moreutils. (full text, mbox, link).


Acknowledgement sent to Erich Schubert <erich@debian.org>:
Extra info received and forwarded to list. Copy sent to Joey Hess <joeyh@debian.org>. (full text, mbox, link).


Message #28 received at 385069@bugs.debian.org (full text, mbox, reply):

From: Erich Schubert <erich@debian.org>
To: Joey Hess <joeyh@debian.org>
Cc: 385069@bugs.debian.org
Subject: Re: diremtpy or "exists"?
Date: Fri, 08 Sep 2006 03:59:51 +0200
Hi,
> I worry though that the tool might be test(1). These seem like fairly
> good candidates to add to test, especially dirempty.

Definitely test should have had this functionality.
However people will expect test to behave the same on all systems, so
I'm not sure adding some non-POSIX extensions to test is a good idea.
People will write scripts and use test, and then it won't work on other
systems. If it's another utility, then it will be much more obvious that
the tool might not exist on other systems.
Furthermore some shells (busybox?) might be using a built-in test, and
that wouldn't have this functionality then.

best regards,
Erich Schubert
-- 
     erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C     (o_
 A man doesn't know what he knows until he knows what he doesn't know. //\
  Man kann sich auch in Gesellschaft anderer einsam fühlen. Weizsäcker V_/_




Information forwarded to debian-bugs-dist@lists.debian.org, Joey Hess <joeyh@debian.org>:
Bug#385069; Package moreutils. (Thu, 13 Jan 2011 14:48:03 GMT) (full text, mbox, link).


Acknowledgement sent to Axel Beckert <abe@debian.org>:
Extra info received and forwarded to list. Copy sent to Joey Hess <joeyh@debian.org>. (Thu, 13 Jan 2011 14:48:03 GMT) (full text, mbox, link).


Message #33 received at 385069@bugs.debian.org (full text, mbox, reply):

From: Axel Beckert <abe@debian.org>
To: 385069@bugs.debian.org
Subject: Just ran into the need for dirempty, too
Date: Thu, 13 Jan 2011 15:45:26 +0100
Hi,

+1 for the inclusion of a dirempty command into moreutils.

	Regards, Ax "The BTS is a voting system" el
-- 
 ,''`.  |  Axel Beckert <abe@debian.org>, http://people.debian.org/~abe/
: :' :  |  Debian Developer, ftp.ch.debian.org Admin
`. `'   |  1024D: F067 EA27 26B9 C3FC 1486  202E C09E 1D89 9593 0EDE
  `-    |  4096R: 2517 B724 C5F6 CA99 5329  6E61 2FF9 CD59 6126 16B5




Added tag(s) patch. Request was from Michael Stummvoll <michael@stummi.org> to control@bugs.debian.org. (Fri, 25 Nov 2011 11:09:25 GMT) (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Joey Hess <joeyh@debian.org>:
Bug#385069; Package moreutils. (Fri, 25 Nov 2011 11:15:25 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Stummvoll <michael@stummi.org>:
Extra info received and forwarded to list. Copy sent to Joey Hess <joeyh@debian.org>. (Fri, 25 Nov 2011 11:15:46 GMT) (full text, mbox, link).


Message #40 received at 385069@bugs.debian.org (full text, mbox, reply):

From: Michael Stummvoll <michael@stummi.org>
To: Debian Bug Tracking System <385069@bugs.debian.org>
Subject: Re: moreutils: Please add "dirempty" command
Date: Fri, 25 Nov 2011 12:06:57 +0100
[Message part 1 (text/plain, inline)]
Package: moreutils
Version: 0.45
Followup-For: Bug #385069

Hi,
cause there didn't happen something to this topic for some years i just made a beginning. :)

Greetings,
Michael

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (700, 'testing'), (650, 'unstable'), (600, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.1.0-1-686-pae (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages moreutils depends on:
ii  libc6            2.13-21 
ii  libipc-run-perl  0.90-1  
ii  perl             5.14.2-5

moreutils recommends no packages.

Versions of packages moreutils suggests:
ii  libtime-duration-perl  <none>  
ii  libtimedate-perl       1.2000-1

-- no debconf information
[dirempty.c (text/plain, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, Joey Hess <joeyh@debian.org>:
Bug#385069; Package moreutils. (Fri, 16 Dec 2011 16:09:03 GMT) (full text, mbox, link).


Acknowledgement sent to Michael Cetrulo <mail2samus@gmail.com>:
Extra info received and forwarded to list. Copy sent to Joey Hess <joeyh@debian.org>. (Fri, 16 Dec 2011 16:09:03 GMT) (full text, mbox, link).


Message #45 received at 385069@bugs.debian.org (full text, mbox, reply):

From: Michael Cetrulo <mail2samus@gmail.com>
To: 385069@bugs.debian.org
Subject: Re: Bug #385069: dirempty/exists
Date: Fri, 16 Dec 2011 14:04:59 -0200
[Message part 1 (text/plain, inline)]
I think you can achieve this with a bash function:

    exists() (
        shopt -s nullglob dotglob; shopt -u failglob
        a=($1); [[ ${a##*/} != . && ${a##*/} != .. && -e $a ]] && return
    )

you'll use it with literal globs (like you do with "find -name" for
instance) eg:

    if exists 'mydir/*'; then
        echo "mydir is not empty"
    else
        echo "mydir is empty"
    fi

also notice the faq cited earlier has moved:
http://mywiki.wooledge.org/BashFAQ/004
[Message part 2 (text/html, inline)]

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Tue Aug 14 21:53:04 2018; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.