zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Cc: Mark Hessling <m.hessling@qut.edu.au>
Subject: Re: Extending zsh capabilities
Date: Mon, 27 Jul 1998 14:13:33 +0200	[thread overview]
Message-ID: <199807271213.OAA02354@hydra.ifh.de> (raw)
In-Reply-To: "Bruce Stephens"'s message of "27 Jul 1998 12:18:16 MST." <vbg1fnk0ef.fsf@snake.isode.com>

Bruce Stephens wrote:
> > Executing a Rexx program within a current process is straighforward,
> > I need to call the API function RexxStart() with the filename as one
> > of the arguments.  The interface is simple; its knowing where to
> > hook it into zsh that is my biggest problem.
> 
> How about, as a first cut, writing a builtin "rexx" which would
> execute a Rexx script?  That could be done as a module (like stat).

I would have thought that was a good place to start; adding additional
capabilities in modules is very much preferred from the development point
of view, and makes it much more likely the code would be acceptable in
the main distribution.  This should be very easy:  just take e.g. stat.c,
rename everything, and prune it right down so that you just have one
function bound to the builtin rexx which calls RexxStart on its filename.

What you really then want is for a shell function beginning /* to run Rexx.
You can do this by sleight of hand.

% fpath=(. $fpath)		# just for convenience in this example
% alias '/*'='rexx_load $0'
% cat rexx_load
local file=$1 dir
for dir in $fpath; do
    [[ -f $dir/$file ]] && file=$dir/$file && break
done

print "Executing $file using Rexx"

# rexx $file

# Now force the calling function to return immediately.
trap 'return 0' EXIT
% cat rtest
/* This is to test rexx_load */
Rexx commands here
% autoload rexx_load rtest
% rtest
Executing ./rtest using Rexx


This works because zsh allows you to alias '/*' which presumably isn't
going to appear as a command anywhere else.  The other tricky bit is
the trap in rexx_load which forces its parent (in this case the function
rtest running under zsh, which you don't want to continue) to return
immediately, since the EXIT trap is executed in the surrounding context.

You could extend rexx_load so that it redefines rtest to run rexx on
a series of commands (if e.g. rexx has a -e switch like perl), eliminating
the intermediate step for subsequent calls.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +39 50 844536
WWW:  http://www.ifh.de/~pws/
Gruppo Teorico, Dipartimento di Fisica
Piazza Torricelli 2, 56100 Pisa, Italy


  reply	other threads:[~1998-07-27 12:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <199807270524.BAA22704@math.gatech.edu>
1998-07-27 10:07 ` Mark Hessling
1998-07-27 11:18   ` Bruce Stephens
1998-07-27 12:13     ` Peter Stephenson [this message]
1998-07-29 22:59       ` Mark Hessling
1998-07-30  8:04         ` Zefram
1998-07-30  8:15         ` Peter Stephenson

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=199807271213.OAA02354@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=m.hessling@qut.edu.au \
    --cc=zsh-workers@math.gatech.edu \
    /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).