mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 12:21:19 -03:00
Only widen string if necessary
This tried a bunch of times, but only the final one is important.
This commit is contained in:
@@ -511,16 +511,18 @@ bool env_universal_t::open_temporary_file(const wcstring &directory, wcstring *o
|
||||
int saved_errno;
|
||||
const wcstring tmp_name_template = directory + L"/fishd.tmp.XXXXXX";
|
||||
|
||||
char *narrow_str = nullptr;
|
||||
for (size_t attempt = 0; attempt < 10 && !success; attempt++) {
|
||||
char *narrow_str = wcs2str(tmp_name_template);
|
||||
narrow_str = wcs2str(tmp_name_template);
|
||||
int result_fd = fish_mkstemp_cloexec(narrow_str);
|
||||
saved_errno = errno;
|
||||
success = result_fd != -1;
|
||||
*out_fd = result_fd;
|
||||
*out_path = str2wcstring(narrow_str);
|
||||
free(narrow_str);
|
||||
}
|
||||
|
||||
*out_path = str2wcstring(narrow_str);
|
||||
free(narrow_str);
|
||||
|
||||
if (!success) {
|
||||
const char *error = std::strerror(saved_errno);
|
||||
debug(0, _(L"Unable to open temporary file '%ls': %s"), out_path->c_str(), error);
|
||||
|
||||
Reference in New Issue
Block a user