zsh-workers
 help / color / mirror / Atom feed
* Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all?
@ 2021-08-04  7:04 Marlon Richert
  2021-08-04 15:52 ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Marlon Richert @ 2021-08-04  7:04 UTC (permalink / raw)
  To: Zsh hackers list

For example:

% print -r -- ${(q+):-{$'\C-['..$'\C-]'}}
'^[' '^\' '^]'
% print -r -- ${(q+):-{$'\C-[',$'\C-]'}}
$'\C-[' $'\C-]'
% setopt braceccl
% print -r -- ${(q+):-{$'\C-['-$'\C-]'}}
$'\C-[' $'\C-\' $'\C-]'
%

Is there a reason for this inconsistency? Why not always produce
quoted or unquoted output?

Also, why bindkey-style quoting? Wouldn't ${(q+)}-style quoting be
more convenient, since it's more straightforward to "unquote"?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all?
  2021-08-04  7:04 Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all? Marlon Richert
@ 2021-08-04 15:52 ` Bart Schaefer
  2021-08-05  6:17   ` Marlon Richert
  0 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2021-08-04 15:52 UTC (permalink / raw)
  To: Marlon Richert; +Cc: Zsh hackers list

On Wed, Aug 4, 2021 at 12:05 AM Marlon Richert <marlon.richert@gmail.com> wrote:
>
> Is there a reason for this inconsistency? Why not always produce
> quoted or unquoted output?
>
> Also, why bindkey-style quoting? Wouldn't ${(q+)}-style quoting be
> more convenient, since it's more straightforward to "unquote"?

The answer to "why doesn't feature A take advantage of feature B" is
often "because A was developed long before B".

I believe that's the case in both instances here.  BRACE_CCL and {x,y}
existed before {a..z}, and {a..z} existed before $'..'.  Old code was
never updated to be consistent with newer code, either from simply
being overlooked, or for backwards compatibility.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all?
  2021-08-04 15:52 ` Bart Schaefer
@ 2021-08-05  6:17   ` Marlon Richert
  2021-08-05 23:36     ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Marlon Richert @ 2021-08-05  6:17 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list

On Wed, Aug 4, 2021 at 6:52 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Wed, Aug 4, 2021 at 12:05 AM Marlon Richert <marlon.richert@gmail.com> wrote:
> >
> > Is there a reason for this inconsistency? Why not always produce
> > quoted or unquoted output?
> >
> > Also, why bindkey-style quoting? Wouldn't ${(q+)}-style quoting be
> > more convenient, since it's more straightforward to "unquote"?
>
> The answer to "why doesn't feature A take advantage of feature B" is
> often "because A was developed long before B".
>
> I believe that's the case in both instances here.  BRACE_CCL and {x,y}
> existed before {a..z}, and {a..z} existed before $'..'.  Old code was
> never updated to be consistent with newer code, either from simply
> being overlooked, or for backwards compatibility.

I just wish {a..z} didn't use quoting at all. :)

I understand, though, that it's hard to change at this point, because
of backwards compatibility.

How would you feel about adding a shell option to make {a..z}
unquoted? (Or failing that, an option to make all of them
$'..'-quoted.)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all?
  2021-08-05  6:17   ` Marlon Richert
@ 2021-08-05 23:36     ` Bart Schaefer
  2021-08-06  0:55       ` Mikael Magnusson
  0 siblings, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2021-08-05 23:36 UTC (permalink / raw)
  To: Marlon Richert; +Cc: Zsh hackers list

On Wed, Aug 4, 2021 at 11:18 PM Marlon Richert <marlon.richert@gmail.com> wrote:
>
> I just wish {a..z} didn't use quoting at all. :)

Re-reading the doc for this, {a..z} is guaranteed to produce PRINTABLE
output, which is not true of the other variations of brace expansion.

> How would you feel about adding a shell option to make {a..z}
> unquoted?

Ambivalent.  If you're going to set an option anyway, why can't you
use BRACE_CCL and {a-z} ?

> (Or failing that, an option to make all of them
> $'..'-quoted.)

That, I think not.  You've already demonstrated that it's simple to
add the quoting ... and in what circumstance would you want the brace
expansion quoted, but the word in which it's embedded, unquoted?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all?
  2021-08-05 23:36     ` Bart Schaefer
@ 2021-08-06  0:55       ` Mikael Magnusson
  2021-08-06  3:08         ` Bart Schaefer
  2021-08-07 19:35         ` Marlon Richert
  0 siblings, 2 replies; 9+ messages in thread
From: Mikael Magnusson @ 2021-08-06  0:55 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Marlon Richert, Zsh hackers list

On 8/6/21, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Wed, Aug 4, 2021 at 11:18 PM Marlon Richert <marlon.richert@gmail.com>
> wrote:
>>
>> I just wish {a..z} didn't use quoting at all. :)
>
> Re-reading the doc for this, {a..z} is guaranteed to produce PRINTABLE
> output, which is not true of the other variations of brace expansion.

If you want to expand these printable representations to the actual
codepoints, you can use (g:ce:) .

>> How would you feel about adding a shell option to make {a..z}
>> unquoted?
>
> Ambivalent.  If you're going to set an option anyway, why can't you
> use BRACE_CCL and {a-z} ?

braceccl works on the byte level only so it's not usable for multibyte
codepoints etc.

>> (Or failing that, an option to make all of them
>> $'..'-quoted.)
>
> That, I think not.  You've already demonstrated that it's simple to
> add the quoting ... and in what circumstance would you want the brace
> expansion quoted, but the word in which it's embedded, unquoted?

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all?
  2021-08-06  0:55       ` Mikael Magnusson
@ 2021-08-06  3:08         ` Bart Schaefer
  2021-08-07 19:35         ` Marlon Richert
  1 sibling, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2021-08-06  3:08 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Marlon Richert, Zsh hackers list

On Thu, Aug 5, 2021 at 5:55 PM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> On 8/6/21, Bart Schaefer <schaefer@brasslantern.com> wrote:
> > On Wed, Aug 4, 2021 at 11:18 PM Marlon Richert <marlon.richert@gmail.com>
> >> How would you feel about adding a shell option to make {a..z}
> >> unquoted?
> >
> > Ambivalent.  If you're going to set an option anyway, why can't you
> > use BRACE_CCL and {a-z} ?
>
> braceccl works on the byte level only so it's not usable for multibyte
> codepoints etc.

Hm, it might make more sense to enable multibyte in braceccl than to
disable quoting in {a..z}.  (Admittedly, it also might be more
difficult.)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all?
  2021-08-06  0:55       ` Mikael Magnusson
  2021-08-06  3:08         ` Bart Schaefer
@ 2021-08-07 19:35         ` Marlon Richert
  2021-08-08  0:09           ` Mikael Magnusson
  1 sibling, 1 reply; 9+ messages in thread
From: Marlon Richert @ 2021-08-07 19:35 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Bart Schaefer, Zsh hackers list

On Fri, Aug 6, 2021 at 3:55 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> On 8/6/21, Bart Schaefer <schaefer@brasslantern.com> wrote:
> > On Wed, Aug 4, 2021 at 11:18 PM Marlon Richert <marlon.richert@gmail.com>
> > wrote:
> >>
> >> I just wish {a..z} didn't use quoting at all. :)
> >
> > Re-reading the doc for this, {a..z} is guaranteed to produce PRINTABLE
> > output, which is not true of the other variations of brace expansion.
>
> If you want to expand these printable representations to the actual
> codepoints, you can use (g:ce:) .

Thanks! I had been looking through
https://zsh.sourceforge.io/Doc/Release/Expansion.html for anything
mentioning `bindkey`, but couldn't find any. :)

> With the c option, sequences like ‘^X’ are also processed.

That could be made more "grep-able".

In general, I think that page could really use a "reverse" index.
Listing parameter flags by letter only doesn't really help in finding
anything. Believe me, I've tried.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all?
  2021-08-07 19:35         ` Marlon Richert
@ 2021-08-08  0:09           ` Mikael Magnusson
  2021-08-10 19:21             ` Marlon Richert
  0 siblings, 1 reply; 9+ messages in thread
From: Mikael Magnusson @ 2021-08-08  0:09 UTC (permalink / raw)
  To: Marlon Richert; +Cc: Bart Schaefer, Zsh hackers list

On 8/7/21, Marlon Richert <marlon.richert@gmail.com> wrote:
> On Fri, Aug 6, 2021 at 3:55 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>>
>> On 8/6/21, Bart Schaefer <schaefer@brasslantern.com> wrote:
>> > On Wed, Aug 4, 2021 at 11:18 PM Marlon Richert
>> > <marlon.richert@gmail.com>
>> > wrote:
>> >>
>> >> I just wish {a..z} didn't use quoting at all. :)
>> >
>> > Re-reading the doc for this, {a..z} is guaranteed to produce PRINTABLE
>> > output, which is not true of the other variations of brace expansion.
>>
>> If you want to expand these printable representations to the actual
>> codepoints, you can use (g:ce:) .
>
> Thanks! I had been looking through
> https://zsh.sourceforge.io/Doc/Release/Expansion.html for anything
> mentioning `bindkey`, but couldn't find any. :)
>
>> With the c option, sequences like ‘^X’ are also processed.
>
> That could be made more "grep-able".
>
> In general, I think that page could really use a "reverse" index.
> Listing parameter flags by letter only doesn't really help in finding
> anything. Believe me, I've tried.

It is indeed always useful when the manpage happens to mention the
exact thing you're looking for, but if it did this in all places and
for everything everyone was looking for, it would be quite a bit
longer :). The documentation for the print builtin also doesn't
mention bindkey, which is why I didn't mention it in the documentation
for g::. The code also doesn't reference bindkey here, fwiw:

    case 'e':
	getkeys |= GETKEY_EMACS;
	break;
    case 'o':
	getkeys |= GETKEY_OCTAL_ESC;
	break;
    case 'c':
	getkeys |= GETKEY_CTRL;
	break;

(although GETKEYS_BINDKEY used presumably for bindkey, is defined as
the combination of exactly those three flags).

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all?
  2021-08-08  0:09           ` Mikael Magnusson
@ 2021-08-10 19:21             ` Marlon Richert
  0 siblings, 0 replies; 9+ messages in thread
From: Marlon Richert @ 2021-08-10 19:21 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Bart Schaefer, Zsh hackers list

On Sun, Aug 8, 2021 at 3:09 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> The documentation for the print builtin also doesn't
> mention bindkey

The documentation for print does, in fact, mention bindkey:

              -b     Recognize all the escape sequences defined for
the bindkey command, see the section `Zle Builtins' in zshzle(1).

Can we give canonical names to these different styles of escape
sequences? That would make it easier to grep for them in the docs.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-08-10 19:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04  7:04 Why does {..} expansion using 'bindkey' quoting, but {,} and BRACE_CCL don't quote at all? Marlon Richert
2021-08-04 15:52 ` Bart Schaefer
2021-08-05  6:17   ` Marlon Richert
2021-08-05 23:36     ` Bart Schaefer
2021-08-06  0:55       ` Mikael Magnusson
2021-08-06  3:08         ` Bart Schaefer
2021-08-07 19:35         ` Marlon Richert
2021-08-08  0:09           ` Mikael Magnusson
2021-08-10 19:21             ` Marlon Richert

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ https://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git