aboutsummaryrefslogtreecommitdiff
path: root/util/fbrun
diff options
context:
space:
mode:
authorThomas Lübking <thomas.luebking@gmail.com>2016-09-18 13:18:04 (GMT)
committerThomas Lübking <thomas.luebking@gmail.com>2016-09-22 19:04:01 (GMT)
commit507782e5d4e21ca9df9bf774228e373d9c3aef8c (patch)
treed820e629239880bdac61060eff55c545c4ed9f2c /util/fbrun
parent39b34a9109ca2a995bbe46a365efa105ecbdf968 (diff)
downloadfluxbox-507782e5d4e21ca9df9bf774228e373d9c3aef8c.zip
fluxbox-507782e5d4e21ca9df9bf774228e373d9c3aef8c.tar.bz2
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.
Diffstat (limited to 'util/fbrun')
-rw-r--r--util/fbrun/FbRun.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc
index 19f6444..780d22a 100644
--- a/util/fbrun/FbRun.cc
+++ b/util/fbrun/FbRun.cc
@@ -482,6 +482,13 @@ void FbRun::tabCompleteApps() {
482 std::string entry = dir.readFilename(); 482 std::string entry = dir.readFilename();
483 if (entry == "." || entry == "..") 483 if (entry == "." || entry == "..")
484 continue; 484 continue;
485 // escape special characters
486 std::string needle(" !\"$&'()*,:;<=>?@[\\]^`{|}");
487 std::size_t pos = 0;
488 while ((pos = entry.find_first_of(needle, pos)) != std::string::npos) {
489 entry.insert(pos, "\\");
490 pos += 2;
491 }
485 if (FbTk::FileUtil::isDirectory(std::string(path + entry).c_str())) 492 if (FbTk::FileUtil::isDirectory(std::string(path + entry).c_str()))
486 m_files.push_back(prefix + entry + "/"); 493 m_files.push_back(prefix + entry + "/");
487 else 494 else