Previous: Redirection, Up: Files

5.17.4 Search Paths

If you specify an absolute filename (i.e., a filename starting with / or ~, or with : in the second position (as in `C:...')) for included and friends, that file is included just as you would expect.

If the filename starts with ./, this refers to the directory that the present file was included from. This allows files to include other files relative to their own position (irrespective of the current working directory or the absolute position). This feature is essential for libraries consisting of several files, where a file may include other files from the library. It corresponds to #include "..." in C. If the current input source is not a file, . refers to the directory of the innermost file being included, or, if there is no file being included, to the current working directory.

For relative filenames (not starting with ./), Gforth uses a search path similar to Forth's search order (see Word Lists). It tries to find the given filename in the directories present in the path, and includes the first one it finds. There are separate search paths for Forth source files and general files. If the search path contains the directory ., this refers to the directory of the current file, or the working directory, as if the file had been specified with ./.

Use ~+ to refer to the current working directory (as in the bash).