[metapost] Input and relative paths
nvitacolonna at gmail.com
Tue Sep 27 21:45:26 CEST 2016
On 2016-09-27 19:23:05 +0000, Reinhard Kotucha said:
> On 2016-09-27 at 18:19:36 +0200, Nicola wrote:
> > Quick question: is using relative paths with (back)slashes portable?
> > I see that both
> > input a/b/c.mp
> > input a\b\c.mp
> > work in macOS (so, I suppose, in *nix systems in general).
> Hi Nicola,
> I'm really wondering that it works for you on OS X at all. On Unix
> the directory separator is the forward slash, unconditionally.
> Backslashes have a special meaning on Unix unless quoted. But even if
> properly quoted, a backslash is never recognized as a directory
> On Linux, for instance:
> *input tmp/foo.mp
> *input tmp\foo.mp
> ! I can't open file `tmp\foo.mp'.
> <*> input tmp\foo.mp
> Please type another input file name:
That has surprised me as well, but indeed it works, even with mixed slashes:
This is MetaPost, version 1.9991 (TeX Live 2016) (kpathsea version 6.2.2)
Preloading the plain mem file, version 1.005) )
Maybe you are using a different version?
>> Can you please confirm that they both work in Windows, too?
> On Windows both are allowed, the MS-DOS API supported them both from
> the beginning. This doesn't mean that you can use forward slashes
> reliably on the command line. But in your case the filename is passed
> from a program to a system call, hence no command-line parsing involed.
> Thus forward slashes are portable, backslashes are not.
> > Also, is it correct that the input command above searches only
> > (a) in the directory from which mpost is launched, but not in its
> > subdirectories (so, it would find ./a/b/c.mp, but not ./x/y/a/b/c.mp);
> > (b) in a set of predefined directories, like /texlive/texmf/metapost,
> > *and* in all of its subdirectories (so, it would find both
> > /texlive/metapost/a/b/c.mp and /texlive/metapost/x/y/a/b/c.mp);
> > in that order?
> Yes, but this is not hard coded into the binary. The configuration
> file is
> I recommend to read the explanations at the top of the file first.
> The current value is
> MPINPUTS = .;$TEXMF/metapost//
> TEXMF contains TEXMFHOME, TEXMFLOCAL, TEXMFDIST, among others, and the
> two trailing slashes denote that subdirectories are searched as well.
> > And this also in Windows?
> TeX Live behaves identical on all platforms, fortunately.
That's very valuable information! I did not know about MPINPUTS: it helps
me solve some headaches I have with finding files in my working directory.
More information about the metapost