GithubHelp home page GithubHelp logo

Comments (4)

barefootcoder avatar barefootcoder commented on June 15, 2024 1

A perusal of File.pm does indeed show it doesn't actually test to make sure the file tests are actually against .... files.

Well, if you come from a Unix background, you're used to the philosophy of "everything is a file": a device is a file, a socket is a file, a symlink is a flle, and, ultimately, a directory is a file too. In later versions of Unixoid systems, directories have diverged from files more significantly, but I'm old enough to remember when you could actually cat a directory. ;-> Of course, in Windows-world, a file and a directory were always completely different animals.

Now, all that having been said: While I don't think it's necessarily a good thing in general for file tests to refuse to work on directories, I do agree that this particular one could be a surprising result. Even more suprising is that, as far as this test is concerned, a directory is never empty: if you run it on a newly created directory, it still says "ok." I suppose that even a fresh directory contains . and .., so in that sense it's not empty, but it still feels a bit wonky.

But, then, what should it do? Should a directory fail both the file_empty_ok test and the file_not_empty_ok test (sort of like a NULL in SQL)? Should it perhaps throw some sort of "don't use file tests on a directory" exception? I'm not entirely sure.

Ultimately this has to be brian d foy's call. I just wanted to weigh in and point out that the answers are not as obvious as one might think. ;->

from test-file.

briandfoy avatar briandfoy commented on June 15, 2024

I've added a test diagnostic message to each of the functions where a directory might be inappropriate. This gives me some time to warn people that these functions might later disallow these things.

from test-file.

briandfoy avatar briandfoy commented on June 15, 2024

I've been thinking a lot about this one, and I'm going to deprecate directories as arguments for these. This basically punts the problem to the future. I'll see what turns up if people get these deprecation messages.

from test-file.

briandfoy avatar briandfoy commented on June 15, 2024

So this is now in v1.991 and I'll see who complains. There have been warnings for a couple years and I haven't heard anyone complain, so we might be good.

If there are more problems, someone can respond to this issue to re-open it, or start a new issue.

from test-file.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.