On 11/05/2012 10:15 AM, Bernhard Voelker wrote:
> My question bases on the discussion in:
>   https://lists.samba.org/archive/rsync/2012-November/027946.html
> where an empty variable $OPTS was passed quoted:
>  $ rsync "$OPTS" -avx from to
> 
> How should a program react for Zero-length arguments?
> Today, coreutils programs give a diagnostic like this:
> 
>   $ cat ''
>   cat: : No such file or directory

That's a literal strerror() output based on the ENOENT error required
for treating an empty string as a file.

> Exceptions are du and wc:
> 
>   $ du ''
>   du: invalid zero-length file name

This situation and others like it are the result of the gnulib module
argv-iter, which obviously filters out empty strings prior to ever
triggering an ENOENT failure.  But the end result is still the same - an
attempt to use an empty string as a file name fails.

> 
> Is this behavior correct / specified somewhere?

Correct, yes.  Specified somewhere?  Well, the generic rule that the
empty file name must cause failure is documented in POSIX; the specific
choice of what error message we issue is not documented.

> At least it should be consistent among coreutils, eh?

Perhaps.  Patches welcome, if you think one or the other style of error
message is worth improving.  But I'm not personally bothered by it.

-- 
Eric Blake   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to