Re: Suggest `isemptydir` for addition to coreutils

2025-07-07 Thread Chris Elvidge
On 07/07/2025 at 07:02, Bernhard Voelker wrote: On 7/6/25 13:11, Stefan Klinger wrote: I've implemented a small tool [1] to test whether a directory is empty, and I think it would make a useful addition to GNU coreutils. IMHO, the number of tools required to implement such a simple test shoul

Re: Suggest `isemptydir` for addition to coreutils

2025-07-06 Thread Bernhard Voelker
On 7/6/25 13:11, Stefan Klinger wrote: I've implemented a small tool [1] to test whether a directory is empty, and I think it would make a useful addition to GNU coreutils. IMHO, the number of tools required to implement such a simple test should be 1, [...] This "dir is empty" information i

Re: Suggest `isemptydir` for addition to coreutils

2025-07-06 Thread Collin Funk
Rob Landley writes: > Do you also need a specific tool to check if a file is zero length? > Because "touch file; [ -f file -a 0 -eq "$(stat -c%s file)" ] && echo > boom" is a similar level of complexity, since merely going stat -c%s > file doesn't prove that file exits and isn't a directory... t

Re: Suggest `isemptydir` for addition to coreutils

2025-07-06 Thread Rob Landley
On 7/6/25 06:11, Stefan Klinger wrote: Hello, I've implemented a small tool [1] to test whether a directory is empty, and I think it would make a useful addition to GNU coreutils. mkdir sub [ -d sub -a -z "$(ls -A sub)" ] && echo boom Is it a directory, is it empty. (Admittedly I didn't chec

Re: Suggest `isemptydir` for addition to coreutils

2025-07-06 Thread Stefan Klinger
Hello Pádraig, and thanks for your kind and swift reply! Pádraig Brady (2025-Jul-06, excerpt): > Anyway I don't think a separate utility is warranted for this > functionality. Fair enough, I'm only *very mildly* disappointed =) > I agree with the thread at [2] that `test -F` may be the best > i

Re: Suggest `isemptydir` for addition to coreutils

2025-07-06 Thread Alain D D Williams
On Sun, Jul 06, 2025 at 01:11:30PM +0200, Stefan Klinger wrote: > Some solutions are more compact and use only shell builtins, e.g., > > $ if ! (shopt -s failglob dotglob; : *) 2>/dev/null; then > echo is empty > fi > > but this may not port nicely to other shells (and has so

Re: Suggest `isemptydir` for addition to coreutils

2025-07-06 Thread Pádraig Brady
On 06/07/2025 12:11, Stefan Klinger wrote: Hello, I've implemented a small tool [1] to test whether a directory is empty, and I think it would make a useful addition to GNU coreutils. There once was a discussion [2] on this mailing list, proposing the extension of `test` with a `-E` flag. AFAI

Suggest `isemptydir` for addition to coreutils

2025-07-06 Thread Stefan Klinger
Hello, I've implemented a small tool [1] to test whether a directory is empty, and I think it would make a useful addition to GNU coreutils. There once was a discussion [2] on this mailing list, proposing the extension of `test` with a `-E` flag. AFAICT this led nowhere, although the topic does