From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4403 invoked from network); 4 Aug 1999 18:14:08 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 Aug 1999 18:14:08 -0000 Received: (qmail 20952 invoked by alias); 4 Aug 1999 18:13:53 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7358 Received: (qmail 20945 invoked from network); 4 Aug 1999 18:13:53 -0000 From: Jeff Solomon MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 4 Aug 1999 11:13:27 -0700 (PDT) To: zsh-workers@sunsite.auc.dk, pws@zsh.org Subject: Zsh and Perl? Message-ID: <14248.30740.258799.3140@mrclean.Stanford.EDU> 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