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

Re: Bug#163190: zsh: Bad indentation in displayed shell function (whence -f)



In the following example, the subshell commands are not indented
uniformly.

> $ blah() { ( echo; echo; echo ) }
> $ whence -f blah
> blah () {
>         ( echo
>                 echo
>                 echo )
> }

Here's one possible fix.  Thoughts?

Index: Src/text.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/text.c,v
retrieving revision 1.11
diff -u -r1.11 text.c
--- Src/text.c	7 Jun 2002 14:44:25 -0000	1.11
+++ Src/text.c	4 Oct 2002 21:43:16 -0000
@@ -345,14 +345,16 @@
 	    break;
 	case WC_SUBSH:
 	    if (!s) {
-		taddstr("( ");
+		taddstr("(");
 		tindent++;
+		taddnl();
 		n = tpush(code, 1);
 		n->u._subsh.end = state->pc + WC_SUBSH_SKIP(code);
 	    } else {
 		state->pc = s->u._subsh.end;
 		tindent--;
-		taddstr(" )");
+		taddnl();
+		taddstr(")");
 		stack = 1;
 	    }
 	    break;



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