[metapost] Input and relative paths

Reinhard Kotucha reinhard.kotucha at web.de
Tue Sep 27 21:23:05 CEST 2016

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: 

> 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.


Reinhard Kotucha                            Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                    mailto:reinhard.kotucha at web.de

More information about the metapost mailing list