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
> interface.  That would be best broached with POSIX folks, or shell
> folks at least.

I would just hate to see it in `usr/bin/test`, and *not* have it in
bash's builtin, that would be unfortunate.

So, yes, “broaching with POSIX folks” sounds very good, especially
since now `-F` and `-E` are on the table.  I would assume such a
feature to then trickle down from POSIX into coreutils and the `test`
builtin of the shells that have one.

How does this broaching work?  The Open Group looks like an uninviting
standards organisation to me, quite intimidating.  Is there any
contact between the you people at GNU/coreutils and those at POSIX?
Just to clarify, I do *not* expect anyone to jump and run just because
I've shown up.  The last time this topic came up [2] on this mailing
list was 2016, so it's obviously not urgent.  I'm asking whether I can
do some of this broaching (sorry, not mocking, just happy to have
learned a new word today), and how so?


> Micheal Stone's request for a concrete use case would be useful,

I'm using “make me a new project” scripts for various situations (eg.,
LaTeX, C, Haskell, Rust), the term “project” is a bit inordinate here.
Anyways, the common pattern is

    $ newproject [path/to/project]

where `path/to/project` is created and subsequently filled with files
generated from an adequate template.

However, if `path/to/project` exists, it is first verified to be empty
(to avoid littering an existing directory with a whole bunch of files
from the template), if it is omitted, `.` is assumed, which is also
verified to be empty.

This is quite convenient (rather than failing on an existing
directory), because all of the following work, and I do use them all:

    $ newproject path/to/project    # if path/to/project does not exist

    $ mkdir path/to/project
    $ newproject path/to/project

    $ mcd path/to/project           # `mcd` is `mkdir` plus `cd`
    $ newproject

In case you're wondering why I'd be so dumb to first create the
directory: It turned out that my brain sometimes works that way, dunno
why, but I've found myself frequently enough with a directory just
created, that I wanted this to just work.


Anyways, I'm a bit averse to arguing by use case: I've seen feature
discussions digress into use case discussions (which sometimes is
helpful, sometimes not so much).

The test “is this directory empty?” asks a simple, obvious question
about a directory, which has a simple answer that should be easy to
give.  However, advice is sought frequently [3] on the web, and the
answers are not so simple [4] (witnessed by variations, caveats and
discussions).  IMHO, this discrepancy is the motivation to add such
functionality.

Anyways, if there's more I can do (maybe try to implement `test -F` or
`test -E`, maybe using code from [1]), give me a hint.  Otherwise, I
don't want to be too pushy, it is certainly not an urgent issue =)

Kind regards
Stefan


[1]: https://github.com/s5k6/isemptydir
[2]: https://lists.gnu.org/archive/html/coreutils/2016-04/msg00024.html
[3]: 
https://www.startpage.com/sp/search?query=linux+shell+test+directory+is+empty&cat=web&pl=opensearch&language=english
[4]: 
https://superuser.com/questions/352289/bash-scripting-test-for-empty-directory
[5]: https://www.gnu.org/software/coreutils/rejected_requests.html


--
Stefan Klinger, Ph.D. -- computer scientist              o/X
http://stefan-klinger.de                                 /\/
https://github.com/s5k6                                    \
I prefer receiving plain text messages, not exceeding 32kB.

Reply via email to