escape special chars in filenames This follows the escaped chars in bash completion and allows to pass filenames with spaces etc. Using quotes would be another option but requires special handling of "~" and, what's worse, either hand-correcting the cursor position (into the quoted area) or more completion mumbo-jumbo to handle the quotes.
Thomas Lübking thomas.luebking@gmail.com
1 files changed,
7 insertions(+),
0 deletions(-)
jump to
M
util/fbrun/FbRun.cc
→
util/fbrun/FbRun.cc
@@ -482,6 +482,13 @@ while (--n > -1) {
std::string entry = dir.readFilename(); if (entry == "." || entry == "..") continue; + // escape special characters + std::string needle(" !\"$&'()*,:;<=>?@[\\]^`{|}"); + std::size_t pos = 0; + while ((pos = entry.find_first_of(needle, pos)) != std::string::npos) { + entry.insert(pos, "\\"); + pos += 2; + } if (FbTk::FileUtil::isDirectory(std::string(path + entry).c_str())) m_files.push_back(prefix + entry + "/"); else