fix path --null-out

Regression from 7bc4c9674bb24f09e0b7af89442f700864217327.

Appending `"\0"` to an std::string does nothing.

I blame C++.
This commit is contained in:
Fabian Boehm 2022-10-05 17:15:56 +02:00
parent 897d95a654
commit dcf52dbba5
2 changed files with 11 additions and 1 deletions

View File

@ -201,7 +201,9 @@ static void path_out(io_streams_t &streams, const options_t &opts, const wcstrin
if (!opts.null_out) { if (!opts.null_out) {
streams.out.append_with_separation(str, separation_type_t::explicitly); streams.out.append_with_separation(str, separation_type_t::explicitly);
} else { } else {
streams.out.append(str + L"\0"); // Note the char - if this was a string instead we'd add
// a string of length 0, i.e. nothing
streams.out.append(str + L'\0');
} }
} }
} }

View File

@ -222,3 +222,11 @@ set -l epochtime (path mtime epoch)
# Allow for timezone shenanigans # Allow for timezone shenanigans
test $epochtime -gt 0 -a $epochtime -lt 180000 test $epochtime -gt 0 -a $epochtime -lt 180000
or echo Oops not mtime or echo Oops not mtime
path basename -Z foo bar baz | path sort
# CHECK: bar
# CHECK: baz
# CHECK: foo
path basename --null-out bar baz | string escape
# CHECK: bar\x00baz\x00