mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
[string] Allow string escape
to handle NULs
TODO: This currently only works for the "script" escaping style. Work towards #4605.
This commit is contained in:
parent
a229f703ae
commit
aedb8dc327
1 changed files with 15 additions and 2 deletions
|
@ -123,6 +123,18 @@ class arg_iterator_t {
|
||||||
}
|
}
|
||||||
return string_get_arg_argv(&argidx_, argv_);
|
return string_get_arg_argv(&argidx_, argv_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wcstring *nextstr() {
|
||||||
|
if (string_args_from_stdin(streams_)) {
|
||||||
|
return get_arg_stdin() ? &storage_ : NULL;
|
||||||
|
}
|
||||||
|
if (auto arg = string_get_arg_argv(&argidx_, argv_)) {
|
||||||
|
storage_ = arg;
|
||||||
|
return &storage_;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,8 +500,9 @@ static int string_escape_script(options_t &opts, int optind, wchar_t **argv,
|
||||||
if (opts.no_quoted) flags |= ESCAPE_NO_QUOTED;
|
if (opts.no_quoted) flags |= ESCAPE_NO_QUOTED;
|
||||||
|
|
||||||
arg_iterator_t aiter(argv, optind, streams);
|
arg_iterator_t aiter(argv, optind, streams);
|
||||||
while (const wchar_t *arg = aiter.next()) {
|
while (auto arg = aiter.nextstr()) {
|
||||||
streams.out.append(escape_string(arg, flags, STRING_STYLE_SCRIPT));
|
// Use the wcstring here because of embedded NULs.
|
||||||
|
streams.out.append(escape_string(*arg, flags, STRING_STYLE_SCRIPT));
|
||||||
streams.out.append(L'\n');
|
streams.out.append(L'\n');
|
||||||
nesc++;
|
nesc++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue