On Fri, Nov 19, 2021 at 07:34:58PM +1059, Reuben ua Bríġ wrote:
> > Date: Fri, 19 Nov 2021 08:30:44 +0100
> > From: Andreas Kusalananda Kähäri
> >
> > Ah, so you are talking about options that takes multiple
> > option-arguments.
>
> That roughly correct for what I was saying about lists, but technically
> the list would be a single argument. It is exactly correct for what I
> meant about signalling globs, that is that a parameter (in the form
> of an array of bits) should be past signalling which arguments are
> expanded from a pattern and therefore definitely filenames.
>
> > That's not how options usually work on Unix, at least not with
> > utilities that uses standard command line parsing.
>
> I was thinking of a glob as a sort of pseudo-single-argument.
> find(1) does have for example
>
> find ! ( -cnewer file1 -cnewer file2 )
>
> which is very analogous if not exactly that.
The predicates of find defines a tiny mini-language. The -cnewer string
(as well as -type, -name, -exec, -ls, etc.) are not options. They make
up the find expression, a set of tests to be carried out on each found
pathname. The find utility has options, but these are given before
the search path(s) on the command line (options always comes before
non-options).
[cut]
> > > to work without first checking the names in '.', and even 'ti' if
> > > compile takes arguments with '/' (if you cant think of any UNIX
> > > utilities that do that, shame on you).
> >
> > I'm not seeing you giving an example.
>
> sed /home/d
The sed utility has two basic ways of being used, just like e.g. the
grep utility (which the OpenBSD manual fails to make clear IMHO; you
can't mix them). The first passes the sed editing expression as the
first non-option argument. The second gives the sed editing expression
as one or a series of -e options with arguments. In each case, quoting
the editing expression(s) is geneally a good idea, unless you want
the shell to perform field splitting and filename generation on the
argument(s).
sed 'expression'
sed -e 'expression' -e 'expression' -e 'expression'
grep 'expression'
grep -e 'expression' -e 'expression' -e 'expression'
What was the thing about "/" and "ti"? Using / unquoted on the command
line is not an issue, neither is using the string "ti". The reason
you want to quote the expressions used with sed and grep is that these
usually contain regular expressions and/or spaces. The shell would
splitt the expression on the spaces if they are unquoted, to generate
multiple arguments. The regular expressions may be intpereted as
globbing patterns.
> Are you talking about zsh here? Or do you know something about ksh?
> I know -a{1,2,3} -> -a1 -a2 -a3 but nothing like -a{*} -> -a*1 -a*2 ...
I'm not sure I understand what you want -a{*} to do. Are "1", "2", etc.
files? If so, *(P[-a]) in zsh, as already mentioned.
>
> > It's already been done by the people developing the zsh shell.
> >
> > compile dir1/*(P[-type1]) dir2/*(P[-type2])
> >
> > This would append "-type1" before each name that dir1/* expands to,
> > and similarly for the second globbing pattern. I'm assuming this is
> > what you were looking for.
> >
> > If you want to match only regular files, include hidden names, and
> > remove the pattern if there are no matches,
> >
> > compile dir1/*(.DNP[-type1]) dir2/*(.DNP[-type2])
>
> Oh thats great to know. Thank you for that. I already knew you can do
>
> c=* cc -c$c
The -c option to cc does not take arguments. If you just want to list
all C files on the command line:
cc -c -- *.c
> in rc(1),
The es shell is available for OpenBSD. It's not quite rc, but may be
close enough.
>but the zsh(1) example you provided here has the nice
> advantage that the flag and its argument are field separated and the
> glob disappears if unmatched. I think this is definitely the best that
> can be done in the shell alone, without modifying utilities to read
> extra parameters, but I am certainly not sold on the sugar (syntax),
> but I will take a look at it.
>
> Cheers for that last one.
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
.