zsh-workers
 help / color / mirror / code / Atom feed
From: Jeff Solomon <jsolomon@stanford.edu>
To: zsh-workers@sunsite.auc.dk, pws@zsh.org
Subject: Zsh and Perl?
Date: Wed,  4 Aug 1999 11:13:27 -0700 (PDT)	[thread overview]
Message-ID: <14248.30740.258799.3140@mrclean.Stanford.EDU> (raw)


Hi,

I'm very sorry if this question seems naive but I've dug a little
through the zsh source code and it seems appropriate.

I think a common task that many people are faced with is writing
little debugging tools. Frequently, they may write such a tool in a
language like Perl because it's so time efficient. Then they realize
that they have no interface for their tool so they either write their
own or they have none at all or mostly have something just like this:

    while( get_input_line_from_terminal_driver ) {
      process_input_line
    }

This makes the interface really, really bad, but the tool writer wants 
to worry about whatever they are debugging (or whatever) and not the
interface.

I've been doing a few of these tools for our research group and I've
gotten pretty good at using libraries like GNU Readline to spruce up
my interfaces, but I find myself constantly trying to emulate what shells
like Zsh already do and do very well.

I've looked at the source for tcsh, bash and now zsh and zsh *by far*
looks the best written and best suited for this task because it seems
so modular.

So I'm asking the zsh developers about the best way to solve this
problem. Basically I want to either embed perl into zsh or embed zsh
into perl, but the key is that my perl commands have to share state
from one instance of a perl interpreter.

Embed perl into zsh:
    
    Looking at the source, this looks like the most straightforward
    thing to do. It seems easy to add a 'perl_eval' command that would 
    evaluate a snippet of perl in a persistent interpreter. But I
    would want to add command into the zsh enviroment from perl so I
    can type:

	my_command my_arg1 my_arg2

    instead of

	perl_eval 'my_command my_arg1 my_arg2'

    which means you'd have to add support for calling back into zsh
    from perl.

Embed zsh into perl:

    zsh is turned into a loadable perl module and I write a script
    directly using zsh. It might look something like this:

    use Shell::Zsh;

    my $zsh = Shell::Zsh->new;

    $zsh->register_command_callback(\&my_callback);

    $zsh->other_customizations.... (add commands for completion, etc)

    $zsh->mainloop;

    sub my_callback {
       process command
    }
    
Anyway, I've gone on long enough. I'm just looking for feedback on
this general idea. Has anyone done this yet? (searching through the
source for 'perl' doesn't find much, and searching the website for
'perl' never returns). Any ideas on which option would be easier to
implement/use?

Any thoughts would be appreciated.

Jeff


             reply	other threads:[~1999-08-04 18:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-04 18:13 Jeff Solomon [this message]
1999-08-04 22:02 ` Bruce Stephens
1999-08-05  5:39 ` Bart Schaefer
1999-08-05  8:31 ` Peter Stephenson
1999-08-23 11:30 Mike Fletcher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14248.30740.258799.3140@mrclean.Stanford.EDU \
    --to=jsolomon@stanford.edu \
    --cc=pws@zsh.org \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).