unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* How to get the preferred environment variable path separator?
@ 2016-03-28  0:42 Chris Marusich
  2016-03-28 10:00 ` Alex Vong
  0 siblings, 1 reply; 10+ messages in thread
From: Chris Marusich @ 2016-03-28  0:42 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 1278 bytes --]

Hi,

Info node "(guile) File System" describes a procedure for getting the
preferred file name separator of the operating system:

--8<---------------cut here---------------start------------->8---
 -- 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.

--8<---------------cut here---------------end--------------->8---

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.

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"?

-- 
Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to get the preferred environment variable path separator?
  2016-03-28  0:42 How to get the preferred environment variable path separator? Chris Marusich
@ 2016-03-28 10:00 ` Alex Vong
  2016-03-28 12:20   ` Thompson, David
  0 siblings, 1 reply; 10+ messages in thread
From: Alex Vong @ 2016-03-28 10:00 UTC (permalink / raw)
  To: Chris Marusich; +Cc: guile-user

Hi,

Chris Marusich <cmmarusich@gmail.com> 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)"))

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



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to get the preferred environment variable path separator?
  2016-03-28 10:00 ` Alex Vong
@ 2016-03-28 12:20   ` Thompson, David
  2016-03-28 13:46     ` Alex Vong
  0 siblings, 1 reply; 10+ messages in thread
From: Thompson, David @ 2016-03-28 12:20 UTC (permalink / raw)
  To: Alex Vong; +Cc: Guile User, Chris Marusich

On Mon, Mar 28, 2016 at 6:00 AM, Alex Vong <alexvong1995@gmail.com> wrote:
> Hi,
>
> Chris Marusich <cmmarusich@gmail.com> 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



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to get the preferred environment variable path separator?
  2016-03-28 12:20   ` Thompson, David
@ 2016-03-28 13:46     ` Alex Vong
  2016-03-28 14:24       ` Thompson, David
  0 siblings, 1 reply; 10+ messages in thread
From: Alex Vong @ 2016-03-28 13:46 UTC (permalink / raw)
  To: Thompson, David; +Cc: Guile User, Chris Marusich

"Thompson, David" <dthompson2@worcester.edu> writes:

> On Mon, Mar 28, 2016 at 6:00 AM, Alex Vong <alexvong1995@gmail.com> wrote:
>> Hi,
>>
>> Chris Marusich <cmmarusich@gmail.com> 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 = "/"
>
I think Christ is asking for ":" instead of "/", do we have environment
path separator in Guile?
>
> - Dave



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to get the preferred environment variable path separator?
  2016-03-28 13:46     ` Alex Vong
@ 2016-03-28 14:24       ` Thompson, David
  2016-03-28 15:36         ` Paul Smith
                           ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Thompson, David @ 2016-03-28 14:24 UTC (permalink / raw)
  To: Alex Vong; +Cc: Guile User, Chris Marusich

On Mon, Mar 28, 2016 at 9:46 AM, Alex Vong <alexvong1995@gmail.com> wrote:
> "Thompson, David" <dthompson2@worcester.edu> writes:
>
>> On Mon, Mar 28, 2016 at 6:00 AM, Alex Vong <alexvong1995@gmail.com> wrote:
>>> Hi,
>>>
>>> Chris Marusich <cmmarusich@gmail.com> 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 = "/"
>>
> I think Christ is asking for ":" instead of "/", do we have environment
> path separator in Guile?

Sorry, I misunderstood.

The environment variable path separator is *not* defined depending on
the OS.  It is up to the programs that interpret these search paths to
specify what the separator should be.  ":" is the most common
separator, but that is just convention.  A search path is opaque to
the operating system, where environment variables are just strings
with no inherent meaning.

Hope this helps.

- Dave



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to get the preferred environment variable path separator?
  2016-03-28 14:24       ` Thompson, David
@ 2016-03-28 15:36         ` Paul Smith
  2016-03-28 15:36         ` Eli Zaretskii
  2016-03-31  4:38         ` Chris Marusich
  2 siblings, 0 replies; 10+ messages in thread
From: Paul Smith @ 2016-03-28 15:36 UTC (permalink / raw)
  To: Thompson, David, Alex Vong; +Cc: Guile User, Chris Marusich

On Mon, 2016-03-28 at 10:24 -0400, Thompson, David wrote:
> The environment variable path separator is *not* defined depending on
> the OS.  It is up to the programs that interpret these search paths 
> to specify what the separator should be.  ":" is the most common
> separator, but that is just convention.  A search path is opaque to
> the operating system, where environment variables are just strings
> with no inherent meaning.

I think this is too simple an answer.  In fact, the operating system
DOES parse the PATH variable (for example on UNIX systems to implement
some of the exec() family of functions).  And on Windows, using ";" as
a separator is a requirement of the operating system as well.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to get the preferred environment variable path separator?
  2016-03-28 14:24       ` Thompson, David
  2016-03-28 15:36         ` Paul Smith
@ 2016-03-28 15:36         ` Eli Zaretskii
  2016-03-28 15:40           ` Thompson, David
  2016-03-29  7:53           ` tomas
  2016-03-31  4:38         ` Chris Marusich
  2 siblings, 2 replies; 10+ messages in thread
From: Eli Zaretskii @ 2016-03-28 15:36 UTC (permalink / raw)
  To: Thompson, David; +Cc: guile-user, cmmarusich

> Date: Mon, 28 Mar 2016 10:24:56 -0400
> From: "Thompson, David" <dthompson2@worcester.edu>
> Cc: Guile User <guile-user@gnu.org>, Chris Marusich <cmmarusich@gmail.com>
> 
> The environment variable path separator is *not* defined depending on
> the OS.  It is up to the programs that interpret these search paths to
> specify what the separator should be.  ":" is the most common
> separator, but that is just convention.  A search path is opaque to
> the operating system, where environment variables are just strings
> with no inherent meaning.

We are not talking about the OS, we are talking about the programs
that set and query environment variables using 'getenv', 'putenv', and
other similar APIs, followed by simple string processing.  And those
are definitely _not_ treating the separator as opaque, something you
can easily verify both by looking at the sources of the respective
applications, and by simple experiments.

And in that sense, the path separator character is always ':' on Posix
systems and ';' on MS-Windows.  So I think Guile ought to have such a
variable; Emacs, for one, does.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to get the preferred environment variable path separator?
  2016-03-28 15:36         ` Eli Zaretskii
@ 2016-03-28 15:40           ` Thompson, David
  2016-03-29  7:53           ` tomas
  1 sibling, 0 replies; 10+ messages in thread
From: Thompson, David @ 2016-03-28 15:40 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Guile User, Chris Marusich

On Mon, Mar 28, 2016 at 11:36 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Mon, 28 Mar 2016 10:24:56 -0400
>> From: "Thompson, David" <dthompson2@worcester.edu>
>> Cc: Guile User <guile-user@gnu.org>, Chris Marusich <cmmarusich@gmail.com>
>>
>> The environment variable path separator is *not* defined depending on
>> the OS.  It is up to the programs that interpret these search paths to
>> specify what the separator should be.  ":" is the most common
>> separator, but that is just convention.  A search path is opaque to
>> the operating system, where environment variables are just strings
>> with no inherent meaning.
>
> We are not talking about the OS, we are talking about the programs
> that set and query environment variables using 'getenv', 'putenv', and
> other similar APIs, followed by simple string processing.  And those
> are definitely _not_ treating the separator as opaque, something you
> can easily verify both by looking at the sources of the respective
> applications, and by simple experiments.
>
> And in that sense, the path separator character is always ':' on Posix
> systems and ';' on MS-Windows.  So I think Guile ought to have such a
> variable; Emacs, for one, does.

OK, sure.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to get the preferred environment variable path separator?
  2016-03-28 15:36         ` Eli Zaretskii
  2016-03-28 15:40           ` Thompson, David
@ 2016-03-29  7:53           ` tomas
  1 sibling, 0 replies; 10+ messages in thread
From: tomas @ 2016-03-29  7:53 UTC (permalink / raw)
  To: guile-user

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Mar 28, 2016 at 06:36:33PM +0300, Eli Zaretskii wrote:
> > Date: Mon, 28 Mar 2016 10:24:56 -0400
> > From: "Thompson, David" <dthompson2@worcester.edu>
> > Cc: Guile User <guile-user@gnu.org>, Chris Marusich <cmmarusich@gmail.com>
> > 
> > The environment variable path separator is *not* defined depending on
> > the OS.  It is up to the programs that interpret these search paths to
> > specify what the separator should be [...]

> We are not talking about the OS, we are talking about the programs
> that set and query environment variables using 'getenv', 'putenv', and
> other similar APIs, followed by simple string processing.  And those
> are definitely _not_ treating the separator as opaque, something you
> can easily verify both by looking at the sources of the respective
> applications, and by simple experiments.
> 
> And in that sense, the path separator character is always ':' on Posix
> systems and ';' on MS-Windows.  So I think Guile ought to have such a
> variable; Emacs, for one, does.

Indeed, this is one of those "it's up to the applications, but things
get weird if you use the 'wrong' one"[1]. Originally it's just a shell
thing, but as Paul noticed upthread, the convention has crept to other
places (execvp and execlp) which are beyond the shells (strictly
speaking it's "just" the libc, and in accordance to POSIX, and for
us oldtimers not "the OS", but hey).

I've had a peek into Perl's and Tcl's sources, and both set that as
a config-time attribute (Perl has one giant hash of config-time things,
and there it's $Config{path_sep}, for example)

So yes, probably Guile should have something like that.

- - - - -
[1] Or perhaps "you can use any character as separator as long as
it is ':'"

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlb6NGwACgkQBcgs9XrR2kakTQCfd000Orm1lqqupeDA4e4MW/64
tKsAn1NGQZ1ctP59rl9yIy38wxfghVgv
=L2pM
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to get the preferred environment variable path separator?
  2016-03-28 14:24       ` Thompson, David
  2016-03-28 15:36         ` Paul Smith
  2016-03-28 15:36         ` Eli Zaretskii
@ 2016-03-31  4:38         ` Chris Marusich
  2 siblings, 0 replies; 10+ messages in thread
From: Chris Marusich @ 2016-03-31  4:38 UTC (permalink / raw)
  To: Thompson, David; +Cc: Guile User

[-- Attachment #1: Type: text/plain, Size: 307 bytes --]

"Thompson, David" <dthompson2@worcester.edu> writes:
> The environment variable path separator is *not* defined depending on
> the OS.

Thank you for the clarification!

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

Ah, I see!  Thank you.

-- 
Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-03-31  4:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-28  0:42 How to get the preferred environment variable path separator? Chris Marusich
2016-03-28 10:00 ` Alex Vong
2016-03-28 12:20   ` Thompson, David
2016-03-28 13:46     ` Alex Vong
2016-03-28 14:24       ` Thompson, David
2016-03-28 15:36         ` Paul Smith
2016-03-28 15:36         ` Eli Zaretskii
2016-03-28 15:40           ` Thompson, David
2016-03-29  7:53           ` tomas
2016-03-31  4:38         ` Chris Marusich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).