Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: subsitutions and beginning of lines.
On 10/13/2015 12:58 PM, Bart Schaefer wrote:
The normal thing when capturing $(...) in an array context is to treat
all adjacent (consecutive) whitespace (characters listed in $IFS) as a
single word break, yes. But the spaces aren't being "stripped down to
a single one". They're being stripped out ENTIRELY, leaving nothing.
It's when putting the array back together into a string again that a
single space is inserted between words.
Ah ... a subtle point but critical. Yes ... I need to 'think array' not
'think string'.
I apologize for my C headedness which refuses to go away.
${${(f)"$(eval history $nnumber $sstring)"}##<->:}
I couldn't get the substitution there to work, but this works fine:
print -l ${${(f)"$(eval history $nnumber $sstring)"}/ #<->??/}
... and I can see that the inner '$(eval ..)' layer will not
molest any spaces at all and each output line is an element unto
itself in an array split on newlines which is then sent for surgery
and then printed one line per element. It's so easy to get it
wrong, but when you get it right, it's down right elegant and not
really obscure at all.
BTW, is there some way of asking history not to search
thru a given number of entries, but to continue searching up to
a given number of hits? Making syntax up:
history -#10 intricate_command
... I find when searching, that what I'm really wanting is a
reasonable number of hits to select from, and my choice of
number for the switch is just a guess which I scale up or
down to achieve some number of hits. I might know that
some time in the last year I entered some command that I'd
like back and I don't really care how far back in history
it was, I just want history to scan backwards until
a match (or several) is found. Can it be done? If not
it would be a feature.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author