Escape spaces in file names for `wordexp`

pull/408/head
jackun 3 years ago
parent fda43f5727
commit 0309b6bbb9
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -239,11 +239,17 @@ parse_path(const char *str)
#ifdef _XOPEN_SOURCE
// Expand ~/ to home dir
if (str[0] == '~') {
std::string s;
std::string s = str;
size_t n = 0;
wordexp_t e;
int ret;
if (!(ret = wordexp(str, &e, 0)))
while ((n = s.find_first_of(" ", n)) != std::string::npos) {
s = s.replace(n, 1, "\\ ");
n += 2;
}
if (!(ret = wordexp(s.c_str(), &e, 0)))
s = e.we_wordv[0];
wordfree(&e);

Loading…
Cancel
Save