coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

paste: handle list ending with unescaped backslash

Open cakebaker opened this issue 3 years ago • 1 comments
trafficstars

Show an error if the user provides a delimiter list ending with an unescaped backslash. For example, paste -d'\' will now show an error whereas paste -d'\\' will work fine.

This makes the tests delim-bs1 and delim-bs2 in https://github.com/coreutils/coreutils/blob/master/tests/misc/paste.pl pass.

cakebaker avatar Jun 22 '22 07:06 cakebaker

Hm, looks like it doesn't work on Windows...

cakebaker avatar Jun 22 '22 12:06 cakebaker

GNU testsuite comparison:

Congrats! The gnu test tests/misc/paste is no longer failing!
GNU test failed: tests/rm/rm2. tests/rm/rm2 is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/tail-2/inotify-dir-recreate. tests/tail-2/inotify-dir-recreate is passing on 'main'. Maybe you have to rebase?

github-actions[bot] avatar Feb 18 '23 21:02 github-actions[bot]

Fails with:

---- test_paste::test_delimiter_list_ending_with_escaped_backslash stdout ----
write(default): C:\Users\RUNNER~1\AppData\Local\Temp\.tmpwTCa7y\in0
write(default): C:\Users\RUNNER~1\AppData\Local\Temp\.tmpwTCa7y\in1
run: D:\a\coreutils\coreutils\target\i686-pc-windows-msvc\debug\coreutils.exe paste -d \\ in0 in1
thread 'test_paste::test_delimiter_list_ending_with_escaped_backslash' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<b
>a\b
 

', tests\by-util\test_paste.rs:172:14
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\panicking.rs:142
   2: tests::common::util::CmdResult::stdout_is<str>
             at .\tests\common\util.rs:444
   3: tests::test_paste::test_delimiter_list_ending_with_escaped_backslash
             at .\tests\by-util\test_paste.rs:169
   4: tests::test_paste::test_delimiter_list_ending_with_escaped_backslash::closure$0
             at .\tests\by-util\test_paste.rs:160
   5: core::ops::function::FnOnce::call_once<tests::test_paste::test_delimiter_list_ending_with_escaped_backslash::closure_env$0,tuple$<> >
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52\library\core\src\ops\function.rs:248
   6: core::ops::function::FnOnce::call_once
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library\core\src\ops\function.rs:248
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    test_paste::test_delimiter_list_ending_with_escaped_backslash

test result: FAILED. 2027 passed; 1 failed; 23 ignored; 0 measured; 0 filtered out; finished in 317.42s

error: test failed, to rerun pass '--test tests'
Error: Process completed with exit code 101.

sylvestre avatar Feb 18 '23 21:02 sylvestre

@cakebaker still interested by this PR ?

sylvestre avatar Mar 27 '23 18:03 sylvestre

GNU testsuite comparison:

Congrats! The gnu test tests/misc/paste is no longer failing!
GNU test failed: tests/tail-2/inotify-dir-recreate. tests/tail-2/inotify-dir-recreate is passing on 'main'. Maybe you have to rebase?

github-actions[bot] avatar Mar 28 '23 01:03 github-actions[bot]

GNU testsuite comparison:

Congrats! The gnu test tests/misc/paste is no longer failing!
GNU test failed: tests/tail-2/inotify-dir-recreate. tests/tail-2/inotify-dir-recreate is passing on 'main'. Maybe you have to rebase?

github-actions[bot] avatar Apr 03 '23 10:04 github-actions[bot]

Failed with:


---- test_paste::test_delimiter_list_ending_with_escaped_backslash stdout ----
write(default): C:\Users\RUNNER~1\AppData\Local\Temp\.tmpqnhKRi\in0
write(default): C:\Users\RUNNER~1\AppData\Local\Temp\.tmpqnhKRi\in1
run: D:\a\coreutils\coreutils\target\debug\coreutils.exe paste -d \\ in0 in1
thread 'test_paste::test_delimiter_list_ending_with_escaped_backslash' panicked at 'assertion failed: `(left == right)`

Diff < left / right > :
<b
>a\b
 

sylvestre avatar Apr 28 '23 07:04 sylvestre

GNU testsuite comparison:

Congrats! The gnu test tests/misc/paste is no longer failing!
Congrats! The gnu test tests/tail-2/inotify-dir-recreate is no longer failing!

github-actions[bot] avatar Apr 28 '23 14:04 github-actions[bot]

As I'm unable to fix the Windows-related issue I disabled the failing test for Windows.

cakebaker avatar Apr 28 '23 14:04 cakebaker

Sounds good, especially with "Congrats! The gnu test tests/misc/paste is no longer failing!" :)

sylvestre avatar Apr 28 '23 14:04 sylvestre