mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:03:57 +08:00
745129e825
A command like "printf nonewline | sed s/x/y/" does not print a concluding newline, whereas "printf nnl | string replace x y" does. This is an edge case -- usually the user input does have a newline at the end -- but it seems still better for this command to just forward the user's data. Teach most string subcommands to check if stdin is missing the trailing newline, and stop adding one in that case. This does not apply when input is read from commandline arguments. * Most subcommands stop adding the final newline, because they don't really care about newlines, so besides their normal processing, they just want to preserve user input. They are: * string collect * string escape/unescape * string join¹ * string lower/upper * string pad * string replace * string repeat * string sub * string trim * string match keeps adding the newline, following "grep". Additionally, for string match --regex, it's important to output capture groups separated by newlines, resulting in multiple output lines for an input line. So it is not obvious where to leave out the newline. * string split/split0 keep adding the newline for the same reason -- they are meant to output multiple elements for a single input line. ¹) string join0 is not changed because it already printed a trailing zero byte instead of the trailing newline. This is consistent with other tools like "find -print0". Closes #3847 |
||
---|---|---|
.. | ||
checks | ||
pexpects | ||
test_functions | ||
.gitignore | ||
history_sample_bash | ||
history_sample_corrupt1 | ||
history_sample_fish_1_x | ||
history_sample_fish_2_0 | ||
interactive.config | ||
interactive.fish | ||
test_driver.sh | ||
test_env.sh | ||
test_util.fish | ||
test.fish |