Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: subsitutions and beginning of lines.
On Oct 12, 10:24pm, Ray Andrews wrote:
}
} and I think my question is still a useful exercise: how would we do that
} if there was no easy way? Combining the words results in a 'command not
} found' error, since it seems to want to believe that 'history -10 |
} ....' is one command
Aren't those two unrelated issues? The "eval" you used is already the
correct way to turn a string formulated as a command line into an actual
command. The array manipulation you asked about would only apply to
the output of the command after eval.
} so I hafta leave the words unmagically joined yet the normal thing
} seems to be to strip spaces down to a single one when making an array
You may need to go back to a specific example, I fear. Making an array
how? By capturing the output of a command?
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.
} It doesn't help that all this splitting is invisible.
This is part and parcel of the whole quoting behavior. Using double
quotes when you don't want splitting is something you need to habituate.
Once the quotes are in place, you can make splitting explicit/visible.
Peter already gave you the ${(f)"${var}"} and ${${(f)"${var}"}##<->:}
incantations; you can use this directly with $(...) as well:
${${(f)"$(eval history $nnumber $sstring)"}##<->:}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author