fold truncates file unexpectedly for multibyte locales
Environment
- Red Hat Enterprise Linux (
RHEL
)7.4
,6.9
coreutils-8.22-18.el7.x86_64
Issue
Command fold -bw n
unexpectedly truncates the line after multiple of n-th byte from the beginning of file (instead of line) if multibyte locale
is used:
# echo -e "abcdef\nghijkl"|fold -bw 4
abcd
ef
g
hijk
l
# echo -e "abcdef\nghijkl"|LANG=C fold -bw 4
abcd
ef
ghij
kl
Resolution
Update to coreutils-8.22-21.el7
or newer, released with Advisory RHBA-2018:0775
Root Cause
The bug was identified and fixed in RHEL 7.5
.
Prior to coreutils-8.22-21.el7
fold -wb
had incorrectly detected and preserved newlines when multi-byte (i.e. en_US.UTF-8
) locale was used.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments