Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: auto-quoting inside braces in arguments



On 2021-02-18 10:30:50 -0800, Bart Schaefer wrote:
> On Thu, Feb 18, 2021 at 9:35 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >
> > Vincent Lefevre wrote on Thu, 18 Feb 2021 13:40 +00:00:
> > > Is there a way to get auto-quoting inside braces in arguments?
> >
> > Proof of concept:
> >
> > f() {
> >   local l=\{ r=\}
> >   CURSOR=${BUFFER[(i)$l]} MARK=${BUFFER[(i)$r]}
> >   (( -- CURSOR ))
> >   zle quote-region
> > }
> 
> It needs to be a bit more complicated than that, because you first
> have to be sure that the braces are not already quoted and do not form
> a valid comma-separated (or ".." range) brace expression.  Also,
> should anything special happen if there is a valid brace expression
> inside the invalid brace pair?   Is this single- or double-quote
> equivalent, or something new?

I think that { would just appear as a quote mechanism until a
matching }. This should probably similar to double-quote.
For instance

  echo {ab cd"ef }" $ZSH_VERSION {0..2} }

should be equivalent to

  echo "{ab cdef } $ZSH_VERSION {0..2} }"

though in practice, there would be only something simple inside { }.
For instance:

  svn diff -r{1 hour ago}

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Messages sorted by: Reverse Date, Date, Thread, Author