fish-shell/tests
Johannes Altmanninger 745129e825 builtin string: don't print final newline if it's missing from stdin
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
2021-11-27 19:11:24 +01:00
..
checks builtin string: don't print final newline if it's missing from stdin 2021-11-27 19:11:24 +01:00
pexpects Make fish_key_reader's output simpler (#8467) 2021-11-22 17:22:22 +01:00
test_functions tests/tmux: Do actually loop 25 times 2021-09-24 18:27:14 +02:00
.gitignore tweak gitignore rules for *tests* directory 2017-02-20 20:29:43 -08:00
history_sample_bash Support $(cmd) command substitution as alternative to (cmd) 2021-07-13 21:33:42 +02:00
history_sample_corrupt1 Improve history robustness against corrupt files 2014-07-29 14:42:03 -07:00
history_sample_fish_1_x Enforce that history items must end with trailing newlines 2021-05-10 14:23:07 -07:00
history_sample_fish_2_0 Enforce that history items must end with trailing newlines 2021-05-10 14:23:07 -07:00
interactive.config Remove some unused functions from the test harness 2020-11-15 09:17:23 +01:00
interactive.fish Add pexpect tests to new test driver 2021-08-29 08:56:12 +02:00
test_driver.sh fix build when path has spaces in it. 2021-10-22 02:27:19 -07:00
test_env.sh tests/test_env.sh: fix copy paste error so we export XDG_RUNTIME_DIR 2021-10-23 18:59:15 +02:00
test_util.fish Run each test fully independently in own environment 2021-08-29 08:56:12 +02:00
test.fish cmake: Force color in the tests 2021-08-30 17:16:19 +02:00