[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 1/2] test: Add unary operator -E: test that a file is an e
From: |
Stephane Chazelas |
Subject: |
Re: [PATCH v2 1/2] test: Add unary operator -E: test that a file is an empty directory |
Date: |
Wed, 13 Apr 2016 16:16:54 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2016-04-07 10:34:56 +0200, Mattias Andrée:
[....]
> + if (!dir)
> + {
> + error (0, errno, "%s", dirname);
> + test_exit (TEST_FAILURE);
> + }
Note that it means it makes it the first operator that would
actually cause "test" to output something.
A test for non-empty without diagnostic output, like for [ -s ]
may be preferable.
For most of the current operators, test returns true if the test
can be performed and the test succeeds and returns false
otherwise without an error message.
For instance, [ -e /secret/file ] would return false if "file"
exists but you don't have search access to "/secret" and you
don't get an error.
> +
> + while (errno = 0, (de = readdir (dir)))
That also means that would be the first operator that has a side
effect: update the access time of the directory.
Note that GNU find has a "-empty" predicate.
Zsh has a "F" (for "full") glob qualifier. *(F) expands to the
non-empty non-hidden directories in the current directory.
[ -F dir ], (for test for non-empty) could be an alternative. It
doesn't seem to be taken by any of the "test" implementation
I've checked.
--
Stephane
- Re: [PATCH] test: Add unary operator -E: test that a file is an empty directory, (continued)
- Re: [PATCH] test: Add unary operator -E: test that a file is an empty directory, Michael Stone, 2016/04/06
- Re: [PATCH] test: Add unary operator -E: test that a file is an empty directory, Mattias Andrée, 2016/04/06
- Re: [PATCH] test: Add unary operator -E: test that a file is an empty directory, Michael Stone, 2016/04/06
- Re: [PATCH] test: Add unary operator -E: test that a file is an empty directory, Mattias Andrée, 2016/04/06
- Re: [PATCH] test: Add unary operator -E: test that a file is an empty directory, Mattias Andrée, 2016/04/06
- Re: [PATCH] test: Add unary operator -E: test that a file is an empty directory, Mattias Andrée, 2016/04/06
[PATCH v2 1/2] test: Add unary operator -E: test that a file is an empty directory, Mattias Andrée, 2016/04/07