From daa7772ad27d8869f58b6d35f1f6a27a8b95864d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ant=C3=B4nio?= Date: Sun, 13 Jun 2021 00:31:34 -0300 Subject: [PATCH] Fix a bug in lines() (after a year of its discovery!) Some time ago, about a year ago, i discovered a bug at `lines()` when incorporating it in a Shell library of mine. Basically, when you ran for the first time, it stored a integer with the number of lines in the `${lines}` variable, which is the expect. But, when you ran it for the second time, it started adding the value of `${lines}`, from the first run, with the value of the current run. The fix to this is very simple, just add `unset` at the end of the function. I had been wanting to do a pull request for a while to fix this, but i've ran out of time and ended up forgetting about it. I hope it helps now. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 97ab1bf..0e3f513 100644 --- a/README.md +++ b/README.md @@ -460,6 +460,7 @@ lines() { done < "$1" printf '%s\n' "$lines" + unset lines } ```