zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: pws-25: typeset +f, functions +
@ 1999-07-06 12:53 Peter Stephenson
  1999-07-06 13:50 ` Andrej Borsenkow
  1999-07-06 14:50 ` Oliver Kiddle
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Stephenson @ 1999-07-06 12:53 UTC (permalink / raw)
  To: Zsh hackers list

If you do `typeset +x' or `typeset -x +' you get just the names of the
exported parameters.  Consequently, `typeset +f' and `functions +'
(functions is claimed to be equivalent to `typeset -f') should just print
the names of the functions.

This is probably a candidate for 3.0.6 if Bart agrees it's a bug fix.

--- Src/builtin.c.pf	Tue Jul  6 14:29:18 1999
+++ Src/builtin.c	Tue Jul  6 14:47:06 1999
@@ -1942,7 +1942,7 @@
     Comp com;
     Shfunc shf;
     int i, returnval = 0;
-    int on = 0, off = 0;
+    int on = 0, off = 0, pflags = 0;
 
     /* Do we have any flags defined? */
     if (ops['u'] == 1)
@@ -1963,13 +1963,17 @@
 	return 1;
     }
 
+    if (ops['f'] == 2 || ops['+'])
+	pflags |= PRINT_NAMEONLY;
+
     /* If no arguments given, we will print functions.  If flags *
      * are given, we will print only functions containing these  *
      * flags, else we'll print them all.                         */
     if (!*argv) {
 	if (ops['U'] && !ops['u'])
 	    on &= ~PM_UNDEFINED;
-	scanhashtable(shfunctab, 1, on|off, DISABLED, shfunctab->printnode, 0);
+	scanhashtable(shfunctab, 1, on|off, DISABLED, shfunctab->printnode,
+		      pflags);
 	return 0;
     }
 
@@ -1982,7 +1986,8 @@
 	    if ((com = parsereg(*argv))) {
 		/* with no options, just print all functions matching the glob pattern */
 		if (!(on|off)) {
-		    scanmatchtable(shfunctab, com, 0, DISABLED, shfunctab->printnode, 0);
+		    scanmatchtable(shfunctab, com, 0, DISABLED,
+				   shfunctab->printnode, pflags);
 		} else {
 		/* apply the options to all functions matching the glob pattern */
 		    for (i = 0; i < shfunctab->hsize; i++) {
@@ -2009,7 +2014,7 @@
 		shf->flags = (shf->flags | (on & ~PM_UNDEFINED)) & ~off;
 	    else
 		/* no flags, so just print */
-		shfunctab->printnode((HashNode) shf, 0);
+		shfunctab->printnode((HashNode) shf, pflags);
 	} else if (on & PM_UNDEFINED) {
 	    /* Add a new undefined (autoloaded) function to the *
 	     * hash table with the corresponding flags set.     */

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: PATCH: pws-25: typeset +f, functions +
  1999-07-06 12:53 PATCH: pws-25: typeset +f, functions + Peter Stephenson
@ 1999-07-06 13:50 ` Andrej Borsenkow
  1999-07-06 14:50 ` Oliver Kiddle
  1 sibling, 0 replies; 5+ messages in thread
From: Andrej Borsenkow @ 1999-07-06 13:50 UTC (permalink / raw)
  To: Zsh hackers list

>
> If you do `typeset +x' or `typeset -x +' you get just the names of the
> exported parameters.  Consequently, `typeset +f' and `functions +'
> (functions is claimed to be equivalent to `typeset -f') should just print
> the names of the functions.
>

That is nice. But a couple more questions about typeset:

- how can I get the names of _scalar_ variables? (I can list integer variables
with typeset +i) In 3.1.5+ with parameter module it is not so interesting - but
for 3.0.6 it may still be useful.

- what does this mean (taken from Zsh typeset docs):

                                                             Using
     `+' rather than `-' to introduce the flag causes the attribute to
     be turned off, and suppresses printing of the names and values.

- the form ``typeset -i +'' (and like) is not documented at all.

- the format of simple ``typeset'' output is not documented as well. It was
great surprise to me once ...

/andrej


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: pws-25: typeset +f, functions +
  1999-07-06 12:53 PATCH: pws-25: typeset +f, functions + Peter Stephenson
  1999-07-06 13:50 ` Andrej Borsenkow
@ 1999-07-06 14:50 ` Oliver Kiddle
  1999-07-07 11:21   ` PATCH: pws-25: alias +, alias +[grm] Oliver Kiddle
  1 sibling, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 1999-07-06 14:50 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson wrote:
> 
> If you do `typeset +x' or `typeset -x +' you get just the names of the
> exported parameters.  Consequently, `typeset +f' and `functions +'
> (functions is claimed to be equivalent to `typeset -f') should just print
> the names of the functions.

That's useful. A similar change should be made for the alias command (so
alias + lists aliases, alias +g lists global aliases etc). This would
also improve ksh compatibility as
it already does this.

Oliver Kiddle


^ permalink raw reply	[flat|nested] 5+ messages in thread

* PATCH: pws-25: alias +, alias +[grm]
  1999-07-06 14:50 ` Oliver Kiddle
@ 1999-07-07 11:21   ` Oliver Kiddle
  1999-07-07 11:43     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 1999-07-07 11:21 UTC (permalink / raw)
  To: Zsh hackers list

Oliver Kiddle wrote:
> Peter Stephenson wrote:
> > If you do `typeset +x' or `typeset -x +' you get just the names of the
> > exported parameters.  Consequently, `typeset +f' and `functions +'
> > (functions is claimed to be equivalent to `typeset -f') should just print
> > the names of the functions.
> That's useful. A similar change should be made for the alias command (so
> alias + lists aliases, alias +g lists global aliases etc). This would
> also improve ksh compatibility as it already does this.

I had a look at doing this and it seemed simple enough so I've done it myself. The
patch is against plain pws-25 so the line numbers may be a bit out. I haven't tested
the doc patch with yodl because I don't have it here so it may have problems. As with
Peter's patch, this might be applicable to 3.0.6.

Hopefully I've sorted my e-mail word wrap problem with this e-mail.

Oliver Kiddle

*** Src/builtin.c.old	Wed Jul  7 09:48:53 1999
--- Src/builtin.c	Wed Jul  7 12:13:23 1999
***************
*** 42,48 ****
      BUILTIN("[", 0, bin_test, 0, -1, BIN_BRACKET, NULL, NULL),
      BUILTIN(".", BINF_PSPECIAL, bin_dot, 1, -1, 0, NULL, NULL),
      BUILTIN(":", BINF_PSPECIAL, bin_true, 0, -1, 0, NULL, NULL),
!     BUILTIN("alias", BINF_MAGICEQUALS, bin_alias, 0, -1, 0, "Lgmr", NULL),
      BUILTIN("autoload", BINF_TYPEOPTS, bin_functions, 0, -1, 0, "tU", "u"),
      BUILTIN("bg", 0, bin_fg, 0, -1, BIN_BG, NULL, NULL),
      BUILTIN("break", BINF_PSPECIAL, bin_break, 0, 1, BIN_BREAK, NULL, NULL),
--- 42,48 ----
      BUILTIN("[", 0, bin_test, 0, -1, BIN_BRACKET, NULL, NULL),
      BUILTIN(".", BINF_PSPECIAL, bin_dot, 1, -1, 0, NULL, NULL),
      BUILTIN(":", BINF_PSPECIAL, bin_true, 0, -1, 0, NULL, NULL),
!     BUILTIN("alias", BINF_MAGICEQUALS | BINF_PLUSOPTS, bin_alias, 0, -1, 0, "Lgmr", NULL),
      BUILTIN("autoload", BINF_TYPEOPTS, bin_functions, 0, -1, 0, "tU", "u"),
      BUILTIN("bg", 0, bin_fg, 0, -1, BIN_BG, NULL, NULL),
      BUILTIN("break", BINF_PSPECIAL, bin_break, 0, 1, BIN_BREAK, NULL, NULL),
***************
*** 2407,2412 ****
--- 2407,2414 ----
  
      if (ops['L'])
  	printflags |= PRINT_LIST;
+     else if (ops['r'] == 2 || ops['g'] == 2 || ops['m'] == 2 || ops['+'])
+ 	printflags |= PRINT_NAMEONLY;
  
      /* In the absence of arguments, list all aliases.  If a command *
       * line flag is specified, list only those of that type.        */
*** Doc/Zsh/builtins.yo.old	Wed Jul  7 11:34:34 1999
--- Doc/Zsh/builtins.yo	Wed Jul  7 11:49:47 1999
***************
*** 44,50 ****
  findex(alias)
  cindex(aliases, defining)
  cindex(aliases, listing)
! item(tt(alias) [ tt(-gmrL) ] [ var(name)[tt(=)var(value)] ... ])(
  For each var(name) with a corresponding var(value), define an alias
  with that value.  A trailing space in var(value) causes the next word
  to be checked for alias expansion.  If the tt(-g) flag is present,
--- 44,50 ----
  findex(alias)
  cindex(aliases, defining)
  cindex(aliases, listing)
! item(tt(alias) [ {tt(PLUS()|tt(-))}tt(gmrL) ] [ var(name)[tt(=)var(value)] ... ])(
  For each var(name) with a corresponding var(value), define an alias
  with that value.  A trailing space in var(value) causes the next word
  to be checked for alias expansion.  If the tt(-g) flag is present,
***************
*** 58,64 ****
  interpreted as glob patterns), and the aliases matching these patterns
  are printed.  When printing aliases and the tt(-g) or tt(-r) flags
  are present, then restrict the printing to global or regular
! aliases, respectively.
  
  If the tt(-L) flag is present, then print each
  alias in a manner suitable for putting in a startup script.  The exit
--- 58,65 ----
  interpreted as glob patterns), and the aliases matching these patterns
  are printed.  When printing aliases and the tt(-g) or tt(-r) flags
  are present, then restrict the printing to global or regular
! aliases, respectively.  Using `tt(PLUS())' instead of `tt(-)' prevents
! the values of the aliases from being printed.
  
  If the tt(-L) flag is present, then print each
  alias in a manner suitable for putting in a startup script.  The exit


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: pws-25: alias +, alias +[grm]
  1999-07-07 11:21   ` PATCH: pws-25: alias +, alias +[grm] Oliver Kiddle
@ 1999-07-07 11:43     ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 1999-07-07 11:43 UTC (permalink / raw)
  To: Zsh hackers list

Oliver Kiddle wrote:
> I had a look at doing this and it seemed simple enough so I've done it myself
> . The
> patch is against plain pws-25 so the line numbers may be a bit out. I haven't
>  tested
> the doc patch with yodl because I don't have it here so it may have problems.

Works fine, and didn't get wrapped.  I still have to look at Andrej's
comments about typeset again.

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-07-07 12:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-06 12:53 PATCH: pws-25: typeset +f, functions + Peter Stephenson
1999-07-06 13:50 ` Andrej Borsenkow
1999-07-06 14:50 ` Oliver Kiddle
1999-07-07 11:21   ` PATCH: pws-25: alias +, alias +[grm] Oliver Kiddle
1999-07-07 11:43     ` Peter Stephenson

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).