From 43d2d280e1b2f842554bb364bde797e32f4ea4f5 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 4 Sep 2019 18:26:37 +0200 Subject: [PATCH] Fix Bash completion for dirs when not using actual dir --- CMakeLists.txt | 2 +- application/argumentparser.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41ffd90..b7bf056 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,7 @@ set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parse set(META_FEATURES_FOR_COMPILER_DETECTION_HEADER cxx_thread_local) set(META_VERSION_MAJOR 5) set(META_VERSION_MINOR 0) -set(META_VERSION_PATCH 0) +set(META_VERSION_PATCH 1) # find required 3rd party libraries include(3rdParty) diff --git a/application/argumentparser.cpp b/application/argumentparser.cpp index 7dd3579..5ef3bd6 100644 --- a/application/argumentparser.cpp +++ b/application/argumentparser.cpp @@ -1521,16 +1521,21 @@ void ArgumentParser::printBashCompletion(int argc, const char *const *argv, unsi continue; } auto dirEntryName = dirEntry.path().filename().string(); + auto hasStartingQuote = false; if (useActualDir) { if (!startsWith(dirEntryName, actualFile)) { continue; } cout << '\''; + hasStartingQuote = true; if (actualDir != ".") { cout << actualDir; } } findAndReplace(dirEntryName, replace, with); + if (!hasStartingQuote) { + cout << '\''; + } cout << dirEntryName << '\'' << ' '; haveFileOrDirCompletions = true; }