Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Improve job text for ( ... ) and { ... }
- X-seq: zsh-workers 27708
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx (Zsh hackers list)
- Subject: Improve job text for ( ... ) and { ... }
- Date: Sat, 13 Feb 2010 20:21:51 +0000
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
The unnecessary and rather confusing first semicolon in
% ( sleep 10 ) &
[1] 9520
% jobs
[1] + running (; sleep 10; )
is entirely cosmetic but nonetheless has been annoying me for a while
now. This removes it. Shout if you see any similar cases I missed.
I realise the ";" after the "sleep 10" is also optional in zsh, but it's
standard and I don't think it's distracting in the same way as the one
before, so I've left it. The alternative would be to make it optional
on some POSIX option, but I don't see the point.
Index: Src/text.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/text.c,v
retrieving revision 1.24
diff -u -r1.24 text.c
--- Src/text.c 11 Sep 2008 17:14:39 -0000 1.24
+++ Src/text.c 13 Feb 2010 20:13:29 -0000
@@ -102,7 +102,7 @@
/**/
static void
-taddnl(void)
+taddnl(int no_semicolon)
{
int t0;
@@ -110,8 +110,11 @@
taddchr('\n');
for (t0 = 0; t0 != tindent; t0++)
taddchr('\t');
- } else
+ } else if (no_semicolon) {
+ taddstr(" ");
+ } else {
taddstr("; ");
+ }
}
/* get a permanent textual representation of n */
@@ -275,7 +278,7 @@
}
if (!(stack = (WC_LIST_TYPE(code) & Z_END))) {
if (tnewlins)
- taddnl();
+ taddnl(0);
else
taddstr((WC_LIST_TYPE(code) & Z_ASYNC) ? " " : "; ");
s->code = *state->pc++;
@@ -355,7 +358,7 @@
if (!s) {
taddstr("(");
tindent++;
- taddnl();
+ taddnl(1);
n = tpush(code, 1);
n->u._subsh.end = state->pc + WC_SUBSH_SKIP(code);
/* skip word only use for try/always */
@@ -363,7 +366,8 @@
} else {
state->pc = s->u._subsh.end;
dec_tindent();
- taddnl();
+ /* semicolon is optional here but more standard */
+ taddnl(0);
taddstr(")");
stack = 1;
}
@@ -372,7 +376,7 @@
if (!s) {
taddstr("{");
tindent++;
- taddnl();
+ taddnl(1);
n = tpush(code, 1);
n->u._subsh.end = state->pc + WC_CURSH_SKIP(code);
/* skip word only use for try/always */
@@ -380,7 +384,8 @@
} else {
state->pc = s->u._subsh.end;
dec_tindent();
- taddnl();
+ /* semicolon is optional here but more standard */
+ taddnl(0);
taddstr("}");
stack = 1;
}
@@ -412,7 +417,7 @@
} else {
taddstr(" () {");
tindent++;
- taddnl();
+ taddnl(1);
n = tpush(code, 1);
n->u._funcdef.strs = state->strs;
n->u._funcdef.end = end;
@@ -423,7 +428,7 @@
state->strs = s->u._funcdef.strs;
state->pc = s->u._funcdef.end;
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("}");
stack = 1;
}
@@ -445,15 +450,15 @@
taddstr(" in ");
taddlist(state, *state->pc++);
}
- taddnl();
+ taddnl(0);
taddstr("do");
}
tindent++;
- taddnl();
+ taddnl(0);
tpush(code, 1);
} else {
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("done");
stack = 1;
}
@@ -467,11 +472,11 @@
taddlist(state, *state->pc++);
}
tindent++;
- taddnl();
+ taddnl(0);
tpush(code, 1);
} else {
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("done");
stack = 1;
}
@@ -484,14 +489,14 @@
tpush(code, 0);
} else if (!s->pop) {
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("do");
tindent++;
- taddnl();
+ taddnl(0);
s->pop = 1;
} else {
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("done");
stack = 1;
}
@@ -500,14 +505,14 @@
if (!s) {
taddstr("repeat ");
taddstr(ecgetstr(state, EC_NODUP, NULL));
- taddnl();
+ taddnl(0);
taddstr("do");
tindent++;
- taddnl();
+ taddnl(0);
tpush(code, 1);
} else {
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("done");
stack = 1;
}
@@ -522,7 +527,7 @@
if (state->pc >= end) {
if (tnewlins)
- taddnl();
+ taddnl(0);
else
taddchr(' ');
taddstr("esac");
@@ -530,7 +535,7 @@
} else {
tindent++;
if (tnewlins)
- taddnl();
+ taddnl(0);
else
taddchr(' ');
taddstr("(");
@@ -559,7 +564,7 @@
break;
}
if (tnewlins)
- taddnl();
+ taddnl(0);
else
taddchr(' ');
taddstr("(");
@@ -588,7 +593,7 @@
}
dec_tindent();
if (tnewlins)
- taddnl();
+ taddnl(0);
else
taddchr(' ');
taddstr("esac");
@@ -610,14 +615,14 @@
stack = 1;
} else if (s->u._if.cond) {
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("then");
tindent++;
- taddnl();
+ taddnl(0);
s->u._if.cond = 0;
} else if (state->pc < s->u._if.end) {
dec_tindent();
- taddnl();
+ taddnl(0);
code = *state->pc++;
if (WC_IF_TYPE(code) == WC_IF_ELIF) {
taddstr("elif ");
@@ -626,12 +631,12 @@
} else {
taddstr("else");
tindent++;
- taddnl();
+ taddnl(0);
}
} else {
s->pop = 1;
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("fi");
stack = 1;
}
@@ -762,7 +767,7 @@
if (!s) {
taddstr("{");
tindent++;
- taddnl();
+ taddnl(0);
n = tpush(code, 0);
state->pc++;
/* this is the end of the try block alone */
@@ -770,14 +775,14 @@
} else if (!s->pop) {
state->pc = s->u._subsh.end;
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("} always {");
tindent++;
- taddnl();
+ taddnl(0);
s->pop = 1;
} else {
dec_tindent();
- taddnl();
+ taddnl(0);
taddstr("}");
stack = 1;
}
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author