Re: [dev] [PATCH 1/2] find: "-" by itself is a file name

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Fri, 2 Nov 2018 14:46:13 +0100

> My interpretation of the linked thread was that "starts with" is
> supposed to mean a strict prefix in POSIX, so "-" doesn't start with
> "-". I haven't found anything in the standard that says that
> explicitly though. If you'd rather interpret "starts with" to include
> exact matches, feel free to drop this patch.

Actually I think you're right.
I mixed the case of "-" and "!", "[()]".

The distinction seems to be explicitely made between “starts with” and
“is”:

“starts with a '-', or is a '!' or a '('”

And I misread the savannah PR example too.

So in fine, I agree with the patch!

Although,

> + return !(arg[0] == '-' && arg[1]) && strcmp(arg, "!") && strcmp(arg, "(");

Having a negation operator at the start of an expression which does
not negate the whole expression chain is kind of misleading.

Why not:

return strcmp(arg, "-") || && strcmp(arg, "!") && strcmp(arg, "(");
Received on Fri Nov 02 2018 - 14:46:13 CET

This archive was generated by hypermail 2.3.0 : Fri Nov 02 2018 - 14:48:06 CET