]> git.corax.cc Git - toolbox/commitdiff
include/log: Don't mangle whitespaces
authorMatthias Kruk <m@m10k.eu>
Tue, 15 Feb 2022 01:33:36 +0000 (10:33 +0900)
committerMatthias Kruk <m@m10k.eu>
Tue, 15 Feb 2022 01:33:36 +0000 (10:33 +0900)
Because IFS is not set in `_log_write()`, logging functions silently
drop whitespace from the beginning and end of each line.

This commit modifies `_log_write()` to set IFS to the empty string
when invoking `read`, so that whitespaces are not stripped.

include/log.sh

index d5e866b8262fa9024c4f5a0495a2fc6bf9a6491d..b9eb3ccc9d2d3fcdd7e5643aa50d2d195ca3bdf5 100644 (file)
@@ -106,7 +106,7 @@ _log_write() {
                        echo "$timestamp $$ $prefix $line" 1>&2
                done
        else
-               while read -r line; do
+               while IFS="" read -r line; do
                        _log_write "$level" "$prefix" "$line"
                done
        fi