diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | manual/qpdf-manual.xml | 8 | ||||
-rw-r--r-- | qpdf/qpdf.cc | 11 |
3 files changed, 24 insertions, 3 deletions
@@ -1,3 +1,11 @@ +2020-03-31 Jay Berkenbilt <ejb@ql.org> + + * 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 <ejb@ql.org> * 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. </para> + <para> + qpdf will use <literal>argv[0]</literal> 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 + <literal>QPDF_EXECUTABLE</literal> environment variable. + </para> </sect1> <sect1 id="ref.basic-options"> <title>Basic Options</title> 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)) { |