Re: Input and relative paths

Nicola <[email protected]>
Newsgroups gmane.comp.tex.metapost
Message-ID <[email protected]>
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
> separator.
> 
> On Linux, for instance:
> 
>    *input tmp/foo.mp
>    (./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:

]mpost
This is MetaPost, version 1.9991 (TeX Live 2016) (kpathsea version 6.2.2)
**\
(/usr/local/texlive/2016/texmf-dist/metapost/base/mpost.mp
(/usr/local/texlive/2016/texmf-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.005) )
*input base/mpiv\mp-tool.mpiv
(/usr/local/texlive/2016/texmf-dist/metapost/context/base/mpiv/mp-tool.mpiv)
*show metapostversion;
>> 1.9991

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
> 
>   texmd-dist/web2c/texmf.cnf
> 
> 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.

Thanks!
Nicola


--
http://tug.org/metapost/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.