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.
This commit is contained in:
parent
39b34a9109
commit
507782e5d4
1 changed files with 7 additions and 0 deletions
|
@ -482,6 +482,13 @@ void FbRun::tabCompleteApps() {
|
||||||
std::string entry = dir.readFilename();
|
std::string entry = dir.readFilename();
|
||||||
if (entry == "." || entry == "..")
|
if (entry == "." || entry == "..")
|
||||||
continue;
|
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()))
|
if (FbTk::FileUtil::isDirectory(std::string(path + entry).c_str()))
|
||||||
m_files.push_back(prefix + entry + "/");
|
m_files.push_back(prefix + entry + "/");
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue