1 2

[PATCH] Correctly trim trailing newlines in $() expansions

Cristian Adrián Ontivero
Details
Message ID
<20190118085657.4880-1-cristianontivero@gmail.com>
Sender timestamp
1547801817
DKIM signature
pass
Download raw message
Patch: +1 -1
Fixes #74
---
 shell/task/word.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shell/task/word.c b/shell/task/word.c
index 3ea074a..1423f34 100644
--- a/shell/task/word.c
+++ b/shell/task/word.c
@@ -185,7 +185,7 @@ static int task_word_poll(struct task *task, struct context *ctx) {
 			tw->fd = -1;
 
 			// Trim newlines at the end
-			ssize_t i = buf.len - 1;
+			ssize_t i = buf.len - 2;
 			while (i >= 0 && buf.data[i] == '\n') {
 				buf.data[i] = '\0';
 				--i;
-- 
2.20.1
Details
Message ID
<XCPPYd3iCHcLyFs9iooKGx37RwJEt2yR-SJr7hVCr20oUfB9YqPY8PHW9SI_F4f0iZgrmxyHz9F8kGowPWOLWVXTVToE_u2HP9ZN07mAFL8=@emersion.fr>
In-Reply-To
<20190118085657.4880-1-cristianontivero@gmail.com> (view parent)
Sender timestamp
1547803140
DKIM signature
pass
Download raw message
Thanks for picking this up!

Pushed:

To git.sr.ht:~emersion/mrsh
   4215cfb..b201f01  master -> master