On Fri, Nov 19, 2021 at 02:40:45PM +1059, Reuben ua Bríġ wrote:
> > Date: Thu, 18 Nov 2021 21:20:36 +0100
> > From: Andreas Kusalananda Kähäri <[email protected]>
> >
> > > all very well if you only need one array of strings, but useless if
> > > you need more.
> >
> > What is the "more" you need?
>
> A greater number of arrays. Using -- is a programming hack/trick that
> allows .one. arbitrary array of arbitrary strings (a list) to be past.
> Say I had a compiler of sorts that takes multiple input files of
> differing types. There is no way I can expect a command like
>
> compile -type1 * -type2 2/*
Ah, so you are talking about options that takes multiple
option-arguments. That's not how options usually work on Unix, at least
not with utilities that uses standard command line parsing. Note that
if some option, -a, takes an option-argument, then there is no issue if
that argument looks like an option, so
utility -a -a
... would call utility with the option -a, and "-a" would be the
option-argument to that option, and there would be no confusion.
>
> 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.
> Even a distributive operator allowing
>
> compile -type1^* -type2^2/*
>
> to be interpreted as
>
> compile -type 1 <*1> -type 1 <*2> ...
>
> would be useful with existing utilities, but Im not aware of any.
Well, "shame on you" then.
> ---
> Im not asking anyway to program this, Im asking if anyone is aware of
> anyone else having already programmed it. Please do read before writing.
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])
--
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden
.