guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get the preferred environment variable path separator?


From: Thompson, David
Subject: Re: How to get the preferred environment variable path separator?
Date: Mon, 28 Mar 2016 08:20:24 -0400

On Mon, Mar 28, 2016 at 6:00 AM, Alex Vong <address@hidden> wrote:
> Hi,
>
> Chris Marusich <address@hidden> writes:
>
>> Hi,
>>
>> Info node "(guile) File System" describes a procedure for getting the
>> preferred file name separator of the operating system:
>>
>>  -- Scheme Variable: file-name-separator-string
>>      The preferred file name separator.
>>
>>      Note that on MinGW builds for Windows, both ‘/’ and ‘\’ are valid
>>      separators.  Thus, programs should not assume that
>>      ‘file-name-separator-string’ is the _only_ file name
>>      separator—e.g., when extracting the components of a file name.
>>
>>
>> Is there an equivalent procedure for getting the preferred environment
>> variable path separator, too?  I would expect such a procedure to return
>> the ":" string (or does it return a character?) on most GNU/Linux
>> distributions, since that is the separator e.g. for the PATH environment
>> variable.
>>
> I can't find one either. If the machine has perl/python, you could try
>   (use-modules (ice-9 rdelim) (ice-9 popen))
>   (read-line (open-pipe* OPEN_READ
>                          "perl"
>                          "-e"
>                          "use Config; print $Config{path_sep}"))
> or
>   (use-modules (ice-9 rdelim) (ice-9 popen))
>   (read-line (open-pipe* OPEN_READ
>                          "python"
>                          "-c"
>                          "import os; print(os.pathsep)"))

Please don't do this.  Use file-name-separator-string.  Section 7.2.3
in the manual, titled "File System".  In Emacs, you can press 'i' to
search the manual for identifiers.

Another way of finding out things like this is to use the REPL:

scheme@(guile-user)> ,a separator
(guile): file-name-separator-string
(guile): file-name-separator?    #<procedure file-name-separator? (c)>
scheme@(guile-user)> file-name-separator-string
$2 = "/"


>> While we're on the topic, Guile's manual has a lot of very nice,
>> detailed information about each module.  However, it does not seem to
>> tell me what the name of the modules are.  Where can I find out what the
>> name of any module described in the manual - e.g. the module which is
>> described in the Info node "(guile) POSIX"?
> I think the procedures described in (guile) POSIX are distributed in
> different modules  E.g, `open-pipe' is located in `(ice-9 popen)', while
> `chdir' is in the global namespace.

Unless otherwise specified, the procedures/variables are in the
default environment.

- Dave



reply via email to

[Prev in Thread] Current Thread [Next in Thread]