zsh-workers
 help / color / mirror / code / Atom feed
* Various notes on KSH_GLOB
@ 2013-05-30 14:30 Christian Neukirchen
  2013-05-30 15:10 ` Peter Stephenson
  2013-05-30 15:53 ` Peter Stephenson
  0 siblings, 2 replies; 3+ messages in thread
From: Christian Neukirchen @ 2013-05-30 14:30 UTC (permalink / raw)
  To: zsh-workers

Hi,

I tried using KSH_GLOB instead of EXTENDED_GLOB recently (because I
really dislike the re-interpretation of ^. What's the benefit over
typing *~?)

However, I stumbled on some problems:

% zsh -f 
juno% zsh --version
zsh 5.0.2 (x86_64-unknown-linux-gnu)
juno% mkdir -p v/v/v/v/v
juno% setopt kshglob
juno% echo *(v|v)
v
juno% echo *(v)
zsh: unknown file attribute
juno% echo *(v|v/)
zsh: bad pattern: *(v|v/)
juno% setopt extendedglob
juno% echo (v/)# 
v/ v/v/ v/v/v/ v/v/v/v/ v/v/v/v/v/

I realize that both mksh and ksh93 neither support directory recursion
with *() (but this would be nice to have, IMO, at last with the explicit
/), which probably only makes this a documentation bug:

>>     *(...) Match any number of occurrences.  (Like `(...)#'.)

Thoughts?

(Perhaps I just need a widget to type \^ when I type ^ after whitespace...)
-- 
Christian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org


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

* Re: Various notes on KSH_GLOB
  2013-05-30 14:30 Various notes on KSH_GLOB Christian Neukirchen
@ 2013-05-30 15:10 ` Peter Stephenson
  2013-05-30 15:53 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2013-05-30 15:10 UTC (permalink / raw)
  To: zsh-workers

On Thu, 30 May 2013 16:30:45 +0200
Christian Neukirchen <chneukirchen@gmail.com> wrote:
> juno% setopt kshglob
>...
> juno% echo *(v)
> zsh: unknown file attribute

You need to "unsetopt bareglobqual".  This would be done automatically
if you were in ksh emulation mode.  Glob qualifiers are parsed first, so
there's no way of making it prefer ksh globs.

> juno% echo *(v|v/)
> zsh: bad pattern: *(v|v/)
> juno% setopt extendedglob
> juno% echo (v/)# 
> v/ v/v/ v/v/v/ v/v/v/v/ v/v/v/v/v/
> 
> I realize that both mksh and ksh93 neither support directory recursion
> with *() (but this would be nice to have, IMO, at last with the explicit
> /), which probably only makes this a documentation bug:
> 
> >>     *(...) Match any number of occurrences.  (Like `(...)#'.)

Yes, it should say there's no equivalent to the (.../)# syntax.

diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 89d5c06..e8d1ed2 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -1957,10 +1957,12 @@ item(tt(@LPAR())...tt(RPAR()))(
 Match the pattern in the parentheses.  (Like `tt(LPAR())...tt(RPAR())'.)
 )
 item(tt(*LPAR())...tt(RPAR()))(
-Match any number of occurrences.  (Like `tt(LPAR())...tt(RPAR()#)'.)
+Match any number of occurrences.  (Like `tt(LPAR())...tt(RPAR()#)',
+except that recursive directory searching is not supported.)
 )
 item(tt(PLUS()LPAR())...tt(RPAR()))(
-Match at least one occurrence.  (Like `tt(LPAR())...tt(RPAR()##)'.)
+Match at least one occurrence.  (Like `tt(LPAR())...tt(RPAR()##)',
+except that recursive directory searching is not supported..)
 )
 item(tt(?LPAR())...tt(RPAR()))(
 Match zero or one occurrence.  (Like `tt(LPAR()|)...tt(RPAR())'.)

pws


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

* Re: Various notes on KSH_GLOB
  2013-05-30 14:30 Various notes on KSH_GLOB Christian Neukirchen
  2013-05-30 15:10 ` Peter Stephenson
@ 2013-05-30 15:53 ` Peter Stephenson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2013-05-30 15:53 UTC (permalink / raw)
  To: zsh-workers

On Thu, 30 May 2013 16:30:45 +0200
Christian Neukirchen <chneukirchen@gmail.com> wrote:
> (Perhaps I just need a widget to type \^ when I type ^ after whitespace...)

This is quite straightforward, by the way...

quote-at-start() {
  if [[ $NUMERIC = '' ]]; then
    [[ $LBUFFER[-1] = ' ' || $LBUFFER = '' ]] && LBUFFER+='\'
  fi
  zle self-insert
}
zle -N quote-at-start
bindkey \^ quote-at-start

That gets confused by

echo 'stuff ^like ^this'

though some magic with split-shell-arguments ought to fix that.  You can
suppress the behaviour with ESC-1 beforehand, though come to think of it
using ^V beforehand is simpler and more obvious.

pws


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

end of thread, other threads:[~2013-05-30 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-30 14:30 Various notes on KSH_GLOB Christian Neukirchen
2013-05-30 15:10 ` Peter Stephenson
2013-05-30 15:53 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).