[GNC] Should the gnc-fq-* helper scripts be invoked as commands, or as an arg to perl?

Chris Good goodchris96 at gmail.com
Mon Jun 14 01:42:48 EDT 2021


Message: 9
Date: Sun, 13 Jun 2021 20:44:18 -0700
From: Jim DeLaHunt <list+gnucash at jdlh.com>
To: gnucash-user at gnucash.org
Subject: Re: [GNC] Should the gnc-fq-* helper scripts be invoked as
	commands, or as an arg to perl?
Message-ID: <96cbda1f-b16d-68be-da69-1e38fdf0ec34 at jdlh.com>
Content-Type: text/plain; charset=utf-8; format=flowed

On 2021-06-13 00:39, Jim DeLaHunt wrote:

> Am I correct in guessing that GnuCash 4.5 internally invokes these 
> scripts (maybe just gnc-fq-helper) as an argument to a perl command?

After a fairly quick read of the source code, I think the answer is, 
"Yes, for over 14 years". I see in gnucash/price-quotes.scm:120-122:

 ??? (define (start-quoter)
 ??? ????? (set! quoter
 ??? ??????? (gnc-spawn-process-async (list "perl" "-w" 
gnc:*finance-quote-helper*) #t)))

I interpret this as meaning that GnuCash fetches quotes by spawning a 
process with arguments like:

perl -w /path/to/helpers/gnc-fq-helper ...[args giving security for 
which to get quotes]...

It looks to me like this code has been much the same since commit 
c38bcd3 on 2007-04-28.? Looking at the code it replaced, I suspect that 
GnuCash used to invoke the scripts directly, without the "perl" "-w" 
part. But that was long ago.

There are comments in libgnucash/quotes/gnc-fq-help.in:75,92 which imply 
direct invocation. They have examples like:

$ echo '(alphavantage "CSCO" "JDSU" "^IXIC")' | ./gnc-fq-helper

But that will only get read by developers, who aren't as easily misled 
as non-developer users.


> If so, should the wiki page 
> https://wiki.gnucash.org/wiki/Online_Quotes use the same invocation?

I am now of the opinion that, yes, it should.

I think that we should guide users to invoke the helper scripts is a 
similar way to how GnuCash actually invokes them. This will help reduce 
user confusion, by making their results more closely match GnuCash's 
results.

I propose to change every invocation on that page from a bare name of 
the helper script

e.g. gnc-fq-dump currency USD EUR

to something like

perl -w gnc-fq-dump currency USD EUR

I will also make sure there is a clear explanation that the above 
abbreviates the path to the helper scripts and the AlphaVantage key. The 
actual invocation is actually more like:

$ ALPHAVANTAGE_API_KEY=01234ABCD perl -w 
/Applications/Gnucash.app/Contents/Resources/bin/gnc-fq-dump currency 
USD EUR

I will also deemphasise the mention of the shebang (#!). It looks like 
the invocation which GnuCash actually uses does not rely on shebang, so 
we should not be leading users to pay attention to it.


Are there objections to me being bold and making such changes?

Best regards,
 ???? ?Jim DeLaHunt

Hi Jim,

Thanks for contributing to the documentation!

I think:
perl -w gnc-fq-dump currency USD EUR
is going to confuse non-technical people just as much.

And using
/Path/To/Perl/perl -w /Path/To/HelperScripts/gnc-fq-dump currency USD EUR
for every example is unnecessarily complicated.

I suggest you just add a section at the start of
https://wiki.gnucash.org/wiki/index.php?title=Online_Quotes#Helper_Scripts
that gives explicit instructions and examples for Linux and macOS like it
current does for
Windows.
Or maybe the later examples should all be stated to be for Linux and have
specific instructions for Windows and macOS at the start of
Helper_Scripts...

I'm pretty sure prefixing commands with the setting of environment variables
(e.g. XYZ=abc command) does not work in Windows.

Running the helper scripts
I'm open to any better suggestions.

Regards, Chris Good




More information about the gnucash-user mailing list