all repos — fluxbox @ 507782e5d4e21ca9df9bf774228e373d9c3aef8c

custom fork of the fluxbox windowmanager

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
commit

507782e5d4e21ca9df9bf774228e373d9c3aef8c

parent

39b34a9109ca2a995bbe46a365efa105ecbdf968

1 files changed, 7 insertions(+), 0 deletions(-)

jump to
M util/fbrun/FbRun.ccutil/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