aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2019-09-28 19:48:19 +0300
committerDylan Araps <dylan.araps@gmail.com>2019-09-28 19:48:19 +0300
commit9e0981752fca795a3eac87ebfac395666776e97b (patch)
tree72bc790d0a1f298435cc8e79eb1831d4253269ac
parentbb10d3173c819c0b9e5fb82bbc4a2bc445706739 (diff)
downloadpure-sh-bible-9e0981752fca795a3eac87ebfac395666776e97b.tar.gz
pure-sh-bible-9e0981752fca795a3eac87ebfac395666776e97b.zip
bible: Fix read stripping leading & trailing IFS whitespace. Closes #8
-rw-r--r--README.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/README.md b/README.md
index fe3ec73..dcb8523 100644
--- a/README.md
+++ b/README.md
@@ -410,7 +410,7 @@ Alternative to the `head` command.
```sh
head() {
# Usage: head "n" "file"
- while read -r line; do
+ while IFS= read -r line; do
printf '%s\n' "$line"
i=$((i+1))
[ "$i" = "$1" ] && return
@@ -458,7 +458,7 @@ lines() {
# 'read' exits with '1' when it sees EOL and
# without the added test, the line isn't sent
# to the loop.
- while read -r line || [ -n "$line" ]; do
+ while IFS= read -r line || [ -n "$line" ]; do
lines=$((lines+1))
done < "$1"
@@ -647,7 +647,7 @@ done
## Loop over the contents of a file
```shell
-while read -r line || [ -n "$line" ]; do
+while IFS= read -r line || [ -n "$line" ]; do
printf '%s\n' "$line"
done < "file"
```