bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extension of file-test primitives?


From: Peter & Kelly Passchier
Subject: Re: extension of file-test primitives?
Date: Wed, 23 Aug 2017 19:55:55 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 08/23/2017 07:36 PM, Greg Wooledge wrote:
Second, you proposed test -fx.  But this collides with existing
multi-character test options.  Specifically, test has the options -e,
-f, and -ef.  So your proposal of letter-concatenation would take
the -e and -f options and squash them together into -ef, which would
collide with the "two files are hard links to the same inode" option.

Likewise, the unary options -n and -t would combine into -nt which
collides with the binary "mtime is newer than" option.

Sure, you might argue that there is no reason to combine -e and -f
together, since one implies the other; or that no sane person would
ever combine -n and -t together; but that's not the point.  The point
is to avoid reader confusion.  It's already bad enough that the -a
option is overloaded and has two completely different meanings.  Let's
not compound that mistake.

I was the one proposing combining the UNARY operators in a way like -fx, and your -a example shows that there is a precedent. Unary and binary operators are different, so there is no confusion for the parser or for the user. It would just work for the person who would like to use it. The combining would only be allowed (and only make sense) for the unary operators, and it would lead to a much cleaner and more readable source. It is also in line with common GNU combining-short-options syntax. Users might even expect this to work already.

This change would not hurt backwards compatibility and enhance bash in a clean way, making things more readable where they would/could be used.

Peter





reply via email to

[Prev in Thread] Current Thread [Next in Thread]