summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tterm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tterm.c b/tterm.c
index 16a3622..6652aab 100644
--- a/tterm.c
+++ b/tterm.c
@@ -131,8 +131,10 @@ loop: if (strncmp(line, "cwd", 3) == 0) {
XStoreName(display, w, cwd);
XFlush(display);
} else if (strncmp(line, "cmd", 3) == 0) {
- line[len-1] = 0;
- line += 3;
+ line[len-1] = 0; len -= 1;
+ line += 3; len -= 3;
+ for (i = len-1; i > 0 && line[i] == ' '; i--)
+ line[i] = 0; /* strip space */
snprintf(cmd, MAX_CMD, "%s (%s)", line, cwd);
XStoreName(display, w, cmd);
XFlush(display);