[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#54470: 29.0.50; [PATCH] Add documentation/tests for Eshell argument
From: |
Jim Porter |
Subject: |
bug#54470: 29.0.50; [PATCH] Add documentation/tests for Eshell argument expansion |
Date: |
Sat, 19 Mar 2022 18:34:44 -0700 |
Eshell supports a few ways of expanding and manipulating arguments:
globs (which most people are likely familiar with from other shells), as
well as predicates (which let you filter lists of file names based on
the files' properties) and modifiers (which perform common
transformations, mostly on lists). However, these lack unit tests and
are currently only documented in the manual as follows:
Eshell’s globbing syntax is very similar to that of Zsh. Users coming
from Bash can still use Bash-style globbing, as there are no
incompatibilities. Most globbing is pattern-based expansion, but
there is also predicate-based expansion. See Filename Generation in
The Z Shell Manual, for full syntax.
As the manual says, the syntax is "similar"; it's not actually the same.
It also doesn't mention argument modifiers, which are related to
predicates, but let you do different things. I think it would be best to
fully-document the syntax so that the Eshell-specific bits are clear.
Attached are some patches to add documentation and tests for this.
For globbing, I only added tests/documentation, but for predicates and
modifiers, I found a few bugs as well. I'll describe each of them:
1. The "is a socket" predicate conflicts with the "is setuid" predicate
(both are `s'), meaning that it's impossible to filter on the setuid
bit. I've updated the "is a socket" predicate to be `=', matching zsh.
2. The "join" (`j') modifier was documented as joining a list and
separating the element by a space, but it actually joined the list with
no separator. It now behaves according to the documentation.
3. The "eval again" (`E') modifier didn't work; it called
`eshell-parse-argument' with one argument, but that function takes no
args. I've fixed this, though I had to make an educated guess on what
the behavior should be. I chose the behavior closest to what the
previous implementation looked like it was trying to do: re-evaluate the
value as though it were a single argument (another option would be to
re-evaluate as though it were a full shell command, i.e. to invoke a
program). I've documented the behavior in the manual, so hopefully that
will explain how it works.
Finally, I added support for the "is effective gid" predicate (`G').
That was already there, but commented out. It just needed uncommenting
and the uid parts renamed to gid. I'm not sure if there was some reason
for it to be commented out, but it works fine in my tests.
Hopefully the documentation I've added is structured/worded reasonably
well. I did my best to follow existing conventions despite the
very-different syntax (especially for predicates/modifiers), and tried
to give a reasonable level of detail for all the options. If there's
anything that's confusing or needs expanded, just let me know and I'll
try to improve it.
Finally, I'm not sure if any of the behavior changes should be
documented in NEWS. `G' ("is effective gid") is a small new feature, and
the change from `s' to `=' for "is a socket" and the change for `j'
(join) are technically incompatible changes, although maybe they're
obscure enough that they don't need NEWS entries. I'll do whatever
others think is best here.
0001-Add-unit-tests-and-documentation-for-Eshell-pattern-.patch
Description: Text document
0002-Add-unit-tests-and-documentation-for-Eshell-predicat.patch
Description: Text document
0003-Add-G-argument-predicate-in-Eshell.patch
Description: Text document
- bug#54470: 29.0.50; [PATCH] Add documentation/tests for Eshell argument expansion,
Jim Porter <=