Re: [R7RS-small] get-environment-variables
Lassi Kortela 01 Dec 2020 21:33 UTC
> PS: SRFI 170, which explicitly wants to implement a subset of POSIX, has
> at least the same encoding problem by (mis)treating what are bytevectors
> as strings. For example, `directory-files` will break as soon as
> filenames appear that cannot be interpreted in the current locale. In
> particular, this means that typical utilities like `ls` or `cp` cannot
> be implemented with SRFI 170.
This can be solved by either:
1. Adding an internal encoding tag to the Scheme implementation's string
type, allowing a program to mix differently-encoded strings. If the
environment variable encoding is unknown, a special encoding tag can be
reserved to indicate that. This is quite non-ideal to require of all
implementations of get-environment-variable.
2. If get-environment-variable is given the variable name as a
bytevector instead of a string, return the value as a bytevector as
well. Python 3 does this: compare the return value of os.listdir("/bin")
and os.listdir(b"/bin").
Pre-SRFI: https://github.com/pre-srfi/process-state-as-bytevectors