On Thu, 3 May 2007, Sven Schreiber wrote:
> set shelldir /some/path
This "set shelldir" thing is very interesting, but it seems
undocumented!? I will think about whether it can be used to solve the
temp file location issue for py4gretl.
I'll make sure it's documented for 1.6.3. It came up in
discussion about scripting with Ignacio (I can't remember now on
which gretl list but it's in the archive somewhere).
> * In the console/script context, should we pay any attention to
> the GUI configuration choice of using the @userdir or the CWD as
> the default for saving files? In the GUI context, this determines
> the location in the filesystem at which the File, Save dialog
> points initially. This could be read over into the console/script
> situation, or not.
Yes I think that would be useful and intuitive, just like the other
settings there are also honored by console/script gretl.
OK, that sounds reasonable.
> * Related to the above, should we make a distinction between the
> filenames "foo" and "./foo" for opening a file for writing in
the
> console/script setting?
Yes, please. I think we actually discussed part of this issue some time
ago when I requested a change of the store/outfile behavior and you were
so kind to do it. The "only" remaining issue is the rule for "./".
The shell itself makes no such
> distinction (well, it does in the case of calling executables, but
> that's not what we're talking about here).
I don't understand this, can you explain?
I'll try! In the shell, it usually makes no difference if you do
touch foo OR touch ./foo
rm foo OR rm ./foo
Either way the operation takes place in the CWD: the second form
makes that explicit, but it's implicit in the first. On the other
hand, "test" versus "./test" (execution) may well make a
difference, depending on the path and the CWD.
So, now, consider
outfile foo --write
vs
outfile ./foo --write
I think maybe we're converging on this (?): (a) if your preference
is set to use @userdir by default, the first variant writes foo to
@userdir but (b) if your preference is to use the CWD, it writes
to the CWD. The second variant, by contrast, always writes to the
CWD.
> One point seems clear: packaged functions should never use
"./"
> filenames (or relative paths at all) unless they're very sure
> what's implied (i.e. unless they have set shelldir or the
> equivalent). Packages should not assume that the startup CWD
> means anything, or is writable by the user.
Well py4gretl uses "./"! :-) Not because it's clean, but because
otherwise one would have to tell the user how to set her preferences for
file saving locations. At least that's what I thought, I realize there
are still things I don't know about gretl scripting. Maybe the shelldir
thing in combination with the @userdir variable makes it unnecessary, I
will think about it.
OK, this is complex. If it's just a matter of writing temporary
files, then I suppose "./" may be OK. (Though it's not guaranteed
that "./" is writable by the user.) I was thinking more of files
that are intended to be findable by the user, and my point was
just that the user may have no idea where "./" is.
More in reply to your second message!
Allin.