zsh-workers
 help / color / mirror / code / Atom feed
* "functions +t" etc. output
@ 2013-02-21 12:33 Peter Stephenson
  2013-02-21 15:54 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 2013-02-21 12:33 UTC (permalink / raw)
  To: Zsh Hackers' List

For "typeset" etc., with flags but no arguments,

       using ‘+’ rather than ‘-’ to introduce the flag
       suppresses printing of the values of parameters when there is no
       parameter  name.

It would seem to me this ought to apply to "functions", in fact it's
even more useful if you want to see the functions with a particular flag
to suppress the body of the function, which might be huge.  But it
doesn't work --- you get the body of the function.

It does work if you add an extra and otherwise redundant "+", which you
don't need in the typeset case, leading me to suppose this is just a
bug.  Same feacha with autoload.

-- 
Peter Stephenson <p.stephenson@samsung.com>       Consultant, Software
Tel: +44 (0)1223 434724              Samsung Cambridge Solution Centre
St John's House, St John's Innovation Park,
Cowley Road, Cambridge, CB4 0DS, UK


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

* Re: "functions +t" etc. output
  2013-02-21 12:33 "functions +t" etc. output Peter Stephenson
@ 2013-02-21 15:54 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2013-02-21 15:54 UTC (permalink / raw)
  To: Zsh Hackers' List

On Thu, 21 Feb 2013 12:33:43 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> For "typeset" etc., with flags but no arguments,
> 
>        using ‘+’ rather than ‘-’ to introduce the flag
>        suppresses printing of the values of parameters when there is no
>        parameter  name.
> 
> It would seem to me this ought to apply to "functions", in fact it's
> even more useful if you want to see the functions with a particular flag
> to suppress the body of the function, which might be huge.  But it
> doesn't work --- you get the body of the function.
> 
> It does work if you add an extra and otherwise redundant "+", which you
> don't need in the typeset case, leading me to suppose this is just a
> bug.  Same feacha with autoload.

Remembering that the option +/-f is only tested for in the caller, if
that's bin_typeset(), and that implicitly turned off flags shouldn't be
included, you get something like this...

diff --git a/Src/builtin.c b/Src/builtin.c
index f13167f..d91c2d9 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2680,7 +2680,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
     Patprog pprog;
     Shfunc shf;
     int i, returnval = 0;
-    int on = 0, off = 0, pflags = 0;
+    int on = 0, off = 0, pflags = 0, roff;
 
     /* Do we have any flags defined? */
     if (OPT_PLUS(ops,'u'))
@@ -2699,16 +2699,21 @@ bin_functions(char *name, char **argv, Options ops, int func)
 	on |= PM_TAGGED_LOCAL;
     else if (OPT_PLUS(ops,'T'))
 	off |= PM_TAGGED_LOCAL;
+    roff = off;
     if (OPT_MINUS(ops,'z')) {
 	on |= PM_ZSHSTORED;
 	off |= PM_KSHSTORED;
-    } else if (OPT_PLUS(ops,'z'))
+    } else if (OPT_PLUS(ops,'z')) {
 	off |= PM_ZSHSTORED;
+	roff |= PM_ZSHSTORED;
+    }
     if (OPT_MINUS(ops,'k')) {
 	on |= PM_KSHSTORED;
 	off |= PM_ZSHSTORED;
-    } else if (OPT_PLUS(ops,'k'))
+    } else if (OPT_PLUS(ops,'k')) {
 	off |= PM_KSHSTORED;
+	roff |= PM_KSHSTORED;
+    }
 
     if ((off & PM_UNDEFINED) || (OPT_ISSET(ops,'k') && OPT_ISSET(ops,'z')) ||
 	(OPT_MINUS(ops,'X') && (OPT_ISSET(ops,'m') || *argv || !scriptname))) {
@@ -2716,7 +2721,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
 	return 1;
     }
 
-    if (OPT_PLUS(ops,'f') || OPT_ISSET(ops,'+'))
+    if (OPT_PLUS(ops,'f') || roff || OPT_ISSET(ops,'+'))
 	pflags |= PRINT_NAMEONLY;
 
     if (OPT_MINUS(ops,'M') || OPT_PLUS(ops,'M')) {

-- 
Peter Stephenson <p.stephenson@samsung.com>       Consultant, Software
Tel: +44 (0)1223 434724              Samsung Cambridge Solution Centre
St John's House, St John's Innovation Park,
Cowley Road, Cambridge, CB4 0DS, UK


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

end of thread, other threads:[~2013-02-21 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-21 12:33 "functions +t" etc. output Peter Stephenson
2013-02-21 15:54 ` 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).