Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: "functions +t" etc. output



On Thu, 21 Feb 2013 12:33:43 +0000
Peter Stephenson <p.stephenson@xxxxxxxxxxx> 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@xxxxxxxxxxx>       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



Messages sorted by: Reverse Date, Date, Thread, Author