diff --git a/src/builtins/path.cpp b/src/builtins/path.cpp index 2c19a2bc6..07d8cb92e 100644 --- a/src/builtins/path.cpp +++ b/src/builtins/path.cpp @@ -201,7 +201,9 @@ static void path_out(io_streams_t &streams, const options_t &opts, const wcstrin if (!opts.null_out) { streams.out.append_with_separation(str, separation_type_t::explicitly); } 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'); } } } diff --git a/tests/checks/path.fish b/tests/checks/path.fish index 8f5d526f3..1e3b0377e 100644 --- a/tests/checks/path.fish +++ b/tests/checks/path.fish @@ -222,3 +222,11 @@ set -l epochtime (path mtime epoch) # Allow for timezone shenanigans test $epochtime -gt 0 -a $epochtime -lt 180000 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