diff --git a/ChangeLog b/ChangeLog index 5cca3465..01fc9eb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2020-03-31 Jay Berkenbilt + + * If QPDF_EXECUTABLE is set, use it as the path to qpdf for + purposes of completion. This variable is only read during the + executation of `qpdf --completion-zsh` and `qpdf + --completion-bash`. It is not used during the actual evaluation of + completions. + 2020-02-22 Jay Berkenbilt * Update pdf-set-form-values.cc to use and mention diff --git a/manual/qpdf-manual.xml b/manual/qpdf-manual.xml index 6ac5029a..e22edc2d 100644 --- a/manual/qpdf-manual.xml +++ b/manual/qpdf-manual.xml @@ -593,6 +593,14 @@ make path, it will warn you, and the completion won't work if you're in a different directory. + + qpdf will use argv[0] to figure out where its + executable is. This may produce unwanted results in some cases, + especially if you are trying to use completion with copy of qpdf + that is built from source. You can specify a full path to the qpdf + you want to use for completion in the + QPDF_EXECUTABLE environment variable. + Basic Options diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index 1f09bb45..de4a0297 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -1599,12 +1599,17 @@ void ArgParser::argCompletionBash() { std::string progname = argv[0]; - // Detect if we're in an AppImage and adjust + std::string executable; std::string appdir; std::string appimage; - if (QUtil::get_env("APPDIR", &appdir) && - QUtil::get_env("APPIMAGE", &appimage)) + if (QUtil::get_env("QPDF_EXECUTABLE", &executable)) { + progname = executable; + } + else if (QUtil::get_env("APPDIR", &appdir) && + QUtil::get_env("APPIMAGE", &appimage)) + { + // Detect if we're in an AppImage and adjust if ((appdir.length() < strlen(argv[0])) && (strncmp(appdir.c_str(), argv[0], appdir.length()) == 0)) {