zsh-workers
 help / color / mirror / code / Atom feed
* Repeatable (@M) bug
@ 2015-08-14  8:53 Sebastian Gniazdowski
  2015-08-14 18:03 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2015-08-14  8:53 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1641 bytes --]

Hello

Summary description: searching for "xyza" doesn't match "xyza", only "xyzab"

Illustration by code:
---------
list=( "aisj" )
echo "1 |${(@M)list:#*aisj*}"
list=( "aisj" "aisja" )
echo "2 |${(@M)list:#*aisja*}"
echo "3 |${(@M)list:#*aisj*}"
list=( "aisj" "aisja" "aisjas" )
echo "4 |${(@M)list:#*aisjas*}"
echo "5 |${(@M)list:#*aisja*}"
echo "6 |${(@M)list:#*aisj*}"
---------

This example works. "aisj" returns "aisj", "aisja" returns "aisja", "aisj"
returns "aisja" AND "aisj", etc. However in a script the same steps yield
the erroneous behavior: "aisj" matches only "aisja" and "aisjas", and
"aisja" matches only "aisjas".

The script is:
https://github.com/psprint/zsh-visual-tools/

It is really simple. It allows to grep for a pattern when displaying
history. Calling the script extends history content - like the 'list=(
"aisj" "aisja" )' lines. Equivalent of the code already mentioned is:

v-list aisj
No matching history entries
v-list aisja
No matching history entries
v-list aisj
(matches only aisja)
v-history aisjas
No matching history entries
v-history aisja
(matches only aisjas)
v-history aisj
(matches only aisja and aisjas)

Also, when I wrote a script to repeat v-history calls automatically (no
through command line) it resulted in:
v-history:fc:21: no such event: 1000

This is a very interesting result, as the `history -rn 1000` call just must
work.

I checked this on OSX 5.0.2 and hombrew's 5.0.8-dev-1.

PS. What I mean by the last mentioned script is:

#!/bin/zsh

autoload v-history

v-history aisj
v-history aisja
v-history aisj
v-history aisjas
v-history aisja
v-history aisj

Best Regards,
Sebastian

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

* Re: Repeatable (@M) bug
  2015-08-14  8:53 Repeatable (@M) bug Sebastian Gniazdowski
@ 2015-08-14 18:03 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2015-08-14 18:03 UTC (permalink / raw)
  To: zsh-workers

On Aug 14, 10:53am, Sebastian Gniazdowski wrote:
}
} Also, when I wrote a script to repeat v-history calls automatically (no
} through command line) it resulted in:
} v-history:fc:21: no such event: 1000
} 
} This is a very interesting result, as the `history -rn 1000` call just must
} work.

Scripts don't normally have history.  How did you run the script?

Glancing through your source code, I suspect the error is not with (@M).

"history 1000" means to start at the 1000th history entry and list up to
the current history entry (which must be event number 1000 or greater,
otherwise you get that "no such event" error).  Adding -r reverses the
order of the output, not the direction of selecting the event numbers.

I suspect you mean "history -rn -1000" to select events up to 1000
history entries ago and list them starting with the current entry.

However, You might avoid running `history -rn` and instead examine
the array $historywords from the zsh/parameter module.  It has all
the individual words from the history with the most recent at the
beginning of the array, which seems to be exactly what you want.

That is, instead of

    list=( `history -rn 1000` )
    list=( "${(@M)list:#*$1*}" )

use

    zmodload zsh/parameter
    list=( "${(@M)historywords:#*$1*}" )


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

end of thread, other threads:[~2015-08-14 18:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-14  8:53 Repeatable (@M) bug Sebastian Gniazdowski
2015-08-14 18:03 ` Bart Schaefer

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).