2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-10-31 19:02:30 +00:00

Use QPDF_EXECUTABLE as a hint for completion

This commit is contained in:
Jay Berkenbilt 2020-03-31 11:38:05 -04:00
parent bb6768b8f0
commit b03e6bd65d
3 changed files with 24 additions and 3 deletions

View File

@ -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> 2020-02-22 Jay Berkenbilt <ejb@ql.org>
* Update pdf-set-form-values.cc to use and mention * Update pdf-set-form-values.cc to use and mention

View File

@ -593,6 +593,14 @@ make
path, it will warn you, and the completion won't work if you're in path, it will warn you, and the completion won't work if you're in
a different directory. a different directory.
</para> </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>
<sect1 id="ref.basic-options"> <sect1 id="ref.basic-options">
<title>Basic Options</title> <title>Basic Options</title>

View File

@ -1599,12 +1599,17 @@ void
ArgParser::argCompletionBash() ArgParser::argCompletionBash()
{ {
std::string progname = argv[0]; std::string progname = argv[0];
// Detect if we're in an AppImage and adjust std::string executable;
std::string appdir; std::string appdir;
std::string appimage; std::string appimage;
if (QUtil::get_env("APPDIR", &appdir) && if (QUtil::get_env("QPDF_EXECUTABLE", &executable))
QUtil::get_env("APPIMAGE", &appimage))
{ {
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])) && if ((appdir.length() < strlen(argv[0])) &&
(strncmp(appdir.c_str(), argv[0], appdir.length()) == 0)) (strncmp(appdir.c_str(), argv[0], appdir.length()) == 0))
{ {