Zsh Mailing List Archive
Messages sorted by:
Re: zle separability
- X-seq: zsh-workers 21203
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: zle separability
- Date: Thu, 28 Apr 2005 08:17:30 +0000
- In-reply-to: <20050428055954.GB6338@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20050424193737.GA27777@xxxxxxxxxxxxxx> <20050424230816.GA78@DervishD> <20050425075146.GC28168@xxxxxxxxxxxxxx> <20050425104950.GA4108@DervishD> <20050425110410.GD28168@xxxxxxxxxxxxxx> <20050425113925.GA4578@DervishD> <20050425115849.GA17635@xxxxxxxxxxxxxx> <1050425160927.ZM24988@xxxxxxxxxxxxxxxxxxxxxxx> <20050428055954.GB6338@xxxxxxxxxxxxxx>
On Apr 27, 10:59pm, Frederik Eaton wrote:
} Subject: Re: zle separability
} On Mon, Apr 25, 2005 at 04:09:27PM +0000, Bart Schaefer wrote:
} > The Functions/Misc/nslookup script in the zsh distribution is the
} > classic example of doing this.
} > zsh -c 'while line=""; vared -e -p "$0: " line; do $0 $=line; done' dig
} Can you describe how history support might be added?
Did you try out and/or look at the Functions/Misc/nslookup script?
It is an example of adding both history and completion by using a
wrapper that calls vared in a loop. It also happens to use zpty to
interpret the interactive prompts of the underlying program, but as
I said you can crop that out if you don't need it.
} > Interactive shells are for interacting with the shell. You don't need
} > an interactive shell to interact with some other command.
} Well on a computer you don't *need* anything to do anything.
Ahem. The point is that the shell is just there to execute other
commands. When you know neither what commands you'll need to execute
nor in what order, then the shell has to be interactive so you can
make a new decision before each command, including choosing things
like changing directory that actually alter the state of the shell.
Conversely, when you know that all you're going to do is repeatedly
run the same command or sequence of commands -- even if possibly with
different inputs or arguments -- then the shell doesn't need to be
interactive. Nothing you type is going to change the state *of the
Note that I'm specifically addressing your request to trap everything
that is typed at a prompt and do something with it other than treat
it as a command. (Which is possible in ZLE by redefining the various
accept-* widgets, or at least their keybindings, but not supported in
the "raw" shell.) That has nothing to do with this:
} But it's come up for me before that this would be a very convnient
} way of doing certain things. If you want a command which will start a
} normal zsh but with a certain environment, you can set the variables
} and hope the user's .zshrc doesn't overwrite them.
You don't have to "hope" that at all. "zsh -f" won't read anything
but the /etc/zshrc file (and you can compile away support for the
/etc files if that's an issue).
} But this isn't ideal, and it doesn't allow you to configure aliases or
You seem to be asking for the ENV feature of ksh (which zsh does in
fact support, when emulating ksh), but that isn't something you need
if you're already writing/running a shell script in the first place.
Bart Schaefer Brass Lantern Enterprises
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by: