You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sed - script parser skips CR, VT, FF (and 0x85, 0xA0) as blanks; GNU skips only space and tab #654
Wherever the script parser skips blanks (between address and command, after a command, before
one-line a/i/c text, before a w/r file name, ...), GNU sed skips only space and tab.
uutils sed skips every Unicode whitespace character, including carriage return, vertical tab,
form feed and the raw bytes 0x85 and 0xA0. As a result:
a script saved with CRLF line endings runs here, where GNU stops with extra characters after command;
a leading \v, \f or \r is silently dropped from one-line a/i/c text and from
file names.
Reproduction
Rust (incorrect)
$ printf'a\n'| ./target/release/sed $'p\r'
a
a
# Exit code: 0
$ printf'a\n'| ./target/release/sed $'1a\vfoo'| od -An -c
a \n f o o \n# Exit code: 0
GNU (correct)
$ printf'a\n'| /usr/bin/sed $'p\r'
/usr/bin/sed: -e expression #1, char 2: extra characters after command# Exit code: 1
$ printf'a\n'| /usr/bin/sed $'1a\vfoo'| od -An -c
a \n\v f o o \n# Exit code: 0
Root cause
ScriptCharProvider::eat_spaces in src/sed/script_char_provider.rs:64-69:
/// Advances the position past any whitespace characters.pubfneat_spaces(&mutself){whileself.pos < self.line.len() && self.current().is_whitespace(){self.advance();}}
current() maps each byte to a char, so char::is_whitespace is also true for the bytes
0x85 and 0xA0 (U+0085, U+00A0).
Activity