Commit b03e6bd65d2144ec3b200c04514bc95cabfc085f
1 parent
bb6768b8
Use QPDF_EXECUTABLE as a hint for completion
Showing
3 changed files
with
24 additions
and
3 deletions
ChangeLog
| 1 | +2020-03-31 Jay Berkenbilt <ejb@ql.org> | |
| 2 | + | |
| 3 | + * If QPDF_EXECUTABLE is set, use it as the path to qpdf for | |
| 4 | + purposes of completion. This variable is only read during the | |
| 5 | + executation of `qpdf --completion-zsh` and `qpdf | |
| 6 | + --completion-bash`. It is not used during the actual evaluation of | |
| 7 | + completions. | |
| 8 | + | |
| 1 | 9 | 2020-02-22 Jay Berkenbilt <ejb@ql.org> |
| 2 | 10 | |
| 3 | 11 | * Update pdf-set-form-values.cc to use and mention | ... | ... |
manual/qpdf-manual.xml
| ... | ... | @@ -593,6 +593,14 @@ make |
| 593 | 593 | path, it will warn you, and the completion won't work if you're in |
| 594 | 594 | a different directory. |
| 595 | 595 | </para> |
| 596 | + <para> | |
| 597 | + qpdf will use <literal>argv[0]</literal> to figure out where its | |
| 598 | + executable is. This may produce unwanted results in some cases, | |
| 599 | + especially if you are trying to use completion with copy of qpdf | |
| 600 | + that is built from source. You can specify a full path to the qpdf | |
| 601 | + you want to use for completion in the | |
| 602 | + <literal>QPDF_EXECUTABLE</literal> environment variable. | |
| 603 | + </para> | |
| 596 | 604 | </sect1> |
| 597 | 605 | <sect1 id="ref.basic-options"> |
| 598 | 606 | <title>Basic Options</title> | ... | ... |
qpdf/qpdf.cc
| ... | ... | @@ -1599,12 +1599,17 @@ void |
| 1599 | 1599 | ArgParser::argCompletionBash() |
| 1600 | 1600 | { |
| 1601 | 1601 | std::string progname = argv[0]; |
| 1602 | - // Detect if we're in an AppImage and adjust | |
| 1602 | + std::string executable; | |
| 1603 | 1603 | std::string appdir; |
| 1604 | 1604 | std::string appimage; |
| 1605 | - if (QUtil::get_env("APPDIR", &appdir) && | |
| 1606 | - QUtil::get_env("APPIMAGE", &appimage)) | |
| 1605 | + if (QUtil::get_env("QPDF_EXECUTABLE", &executable)) | |
| 1607 | 1606 | { |
| 1607 | + progname = executable; | |
| 1608 | + } | |
| 1609 | + else if (QUtil::get_env("APPDIR", &appdir) && | |
| 1610 | + QUtil::get_env("APPIMAGE", &appimage)) | |
| 1611 | + { | |
| 1612 | + // Detect if we're in an AppImage and adjust | |
| 1608 | 1613 | if ((appdir.length() < strlen(argv[0])) && |
| 1609 | 1614 | (strncmp(appdir.c_str(), argv[0], appdir.length()) == 0)) |
| 1610 | 1615 | { | ... | ... |