From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19245 invoked from network); 23 Feb 1998 22:24:12 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 23 Feb 1998 22:24:12 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id RAA02065; Mon, 23 Feb 1998 17:04:28 -0500 (EST) Resent-Date: Mon, 23 Feb 1998 17:04:28 -0500 (EST) Message-Id: <199802232206.QAA24472@simon.er.usgs.gov> X-Face: n6^E~>y8=`I>z#<]WKN-(s:<*TU7^z@n%b-LfT"PIprgHagJkRh-OLIqVm?[@^5x -N?77QrhM.v=qRq5F;2m)TL<%Y>h$2O9I,'3urb^^!zwI8OQPdsF|?w?mLdJ+\w# o#wF<,F}rliB.5KLWfwQ4.&QoQ\8!-L?'_Ub6)IGI1S)ZF0,TsN(d3@Y"fZy0rx} /_u#|]#*b/w1~Jo@gw1h(;W0hL X-Rumor: Time is an enourmous long river, and I am standing in it. To: zsh-workers@math.gatech.edu Subject: Re: default command function In-reply-to: <199802231939.NAA00585@simon.er.usgs.gov> From: "Gregory D. Fast" Date: Mon, 23 Feb 1998 16:06:39 -0600 Sender: gdfast@simon.er.usgs.gov Resent-Message-ID: <"HRMZo.0.CW.i9Vyq"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3787 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Thus spake "Gregory D. Fast" : >Is there a better way to do this? My patch against 3.0.5 follows. Oops. That was the ugly patch. This one is a lot cleaner (they both work, though). -- Greg Fast --- zsh-3.0.5/Src/exec.c Thu Sep 25 20:42:16 1997 +++ zsh-3.0.5-gdf/Src/exec.c Mon Feb 23 12:53:38 1998 @@ -1,5 +1,5 @@ /* - * $Id: exec.c,v 2.93 1996/10/15 20:16:35 hzoli Exp $ + * $Id: exec.c,v 1.8 1998/02/23 18:53:18 gdfast Exp gdfast $ * * exec.c - command execution * @@ -347,8 +347,38 @@ } if (eno) zerr("%e: %s", arg0, eno); - else - zerr("command not found: %s", arg0, 0); +#ifdef DEFAULT_CMD + else { + /* if cmd is unknown and function _default_cmd() is defined, + * call _default_cmd() with the faulty cmdline as its args + */ + char *cmdarg = "_default_cmd"; + List f; /* Shfunc to execute */ + LinkNode top; + char * cxx; + LinkList fargs = newlinklist(); + + addlinknode(fargs, (void *) cmdarg); /* make $0 "_default_cmd" */ + /* args is global */ + top = firstnode(args); /* keep track of where to stop rolling args */ + do { + cxx = (char *) peekfirst(args); + addlinknode(fargs, (void *) cxx); + if (args->first->next==NULL) { + break; /* don't roll if there's nowhere to roll to */ + } + rolllist(args, args->first->next); + } while (args->first!=top); + if ( (f=getshfunc(cmdarg)) ) { + doshfunc(f, fargs, 0, 1); + } else { + zerr("command not found and no _default_cmd(): %s", arg0, 0); + } + } +#else /* no DEFAULT_CMD */ + else + zerr("command not found: %s", arg0, 0); +#endif /* DEFAULT_CMD */ _exit(1); }