Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zle separability

On Mon, Apr 25, 2005 at 04:09:27PM +0000, Bart Schaefer wrote:
> On Apr 25, 12:51am, Frederik Eaton wrote:
> }
> } Thanks. I guess there's always writing a zsh script to do the
> } interfacing, but that wouldn't be ideal.
> The Functions/Misc/nslookup script in the zsh distribution is the
> classic example of doing this.  If your underlying command doesn't
> expect to print its own prompts on a terminal, you can even leave
> out the zpty stuff and just do a "while vared" loop.
> } (... but, by the way, it would still be nice if such uses for zsh were
> } better supported, with for instance support for reading an arbitrary
> } config file or executing an arbitrary fragment before opening an
> } interactive shell, or for a function which can be defined to handle
> } all interactive commands)
> 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. 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. But this isn't ideal, and it
doesn't allow you to configure aliases or functions.

It's not a big deal, I don't know how many others would use it, but I
was surprised to find out that it wasn't a feature.

I have this at the end of my .zshrc, but the fact that it's not
standard (and I would choose a different variable name if it were)
means that there are drawbacks to relying on it in anything I
distribute to others.

if [ -n $RC_CMD ]; then
    eval "$RC_CMD"
    export RC_CMD=

> E.g. to repeatedly read command-line arguments of "dig" and then
> call dig with those arguments:
> zsh -c 'while line=""; vared -e -p "$0: " line; do $0 $=line; done' dig
> The use of $0 means you can replace "dig" above with any other command
> name and it'll work the same way.  It's a little trickier if you want
> to add history support, but not too bad.

Can you describe how history support might be added?



Messages sorted by: Reverse Date, Date, Thread, Author