Zsh Mailing List Archive
Messages sorted by:
Re: write a command line.
On Sat, Apr 14, 2012 at 12:42 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> On 14/04/12 12:03 PM, Bart Schaefer wrote:
>> Usually a "script" refers to something that runs as a stand-alone
>> program separate from an interactive shell. "print -z" in a script
>> would be meaningless, whereas your original solution of appending to
>> the incrementally-shared history file works perfectly for such an
>> external program. If "print -z" really works for you, you must be
>> referring to a "function" rather than a "script.
> Well, as a trivial example, this works:
> export string="echo $PATH"
> print -z $string
In saying "this works" you've still only told half the story. How do
those several lines of code get executed? Apparently they're in a
file. Do you read that file with the "source" command (or its cryptic
synonym ".")? Do you pass the file name to "autoload" and then type
its name? Or do you just put the file in a directory in your $path
somewhere and then type its name?
The most common meaning of "script" is the last of those, and the next
most common is the first of those, but only the first two will do
anything useful with "print -z". If you did the second,
congratulations, you've made a "function" -- that's what autoload
does, it creates functions.
>> I have problem X. I come up with a solution which involves steps A,
>> B, C, and D, but I run into a problem at step C. Instead of
>> describing the original problem X, I attempt to describe the execution
>> of C, and everyone gets lost in the details.
> Very true. For example with my problem people were trying to help me with
> 'zle' and 'bindkey' whereas the real problem was ignored. Mikael saw that
> 'zle' and 'bindkey' are irrelevant, they are only 'A,B,C' whereas what is
> wanted is 'X'.
With all respect, you've missed the point. You've never yet explained
what problem you have that is solved by this script that contains
"print -z". Having a script or function to construct something to put
on the command line for you to edit is a step B for which "print -z"
is step C and you doing the editing is step D. But why did you need
to get there in the first place?
The people who were telling you about zle and bindkey were attempting
to guess what X is. Mikael just ignored that and answered your
question in the most direct way possible. (Of course I'm now
answering in the most indirect way possible. :-)
For example, given the snippet above that you say works the way you
want it to, I might also try to guess what X is, and ask: Have you
tried the "vared" command?
% vared path
Messages sorted by: