Patch #957650: "%var%" environment variable references are now properly

expanded in ntpath.expandvars(), also "~user" home directory references
are recognized and handled on Windows.
This commit is contained in:
Georg Brandl 2007-03-13 22:07:36 +00:00
parent b6ae6aa8ac
commit 03b90d8cfd
4 changed files with 64 additions and 22 deletions

View file

@ -58,18 +58,20 @@ Equivalent to \function{exists()} on platforms lacking
\end{funcdesc}
\begin{funcdesc}{expanduser}{path}
On \UNIX, return the argument with an initial component of \samp{\~} or
\samp{\~\var{user}} replaced by that \var{user}'s home directory.
An initial \samp{\~} is replaced by the environment variable
On \UNIX and Windows, return the argument with an initial component of
\samp{\~} or \samp{\~\var{user}} replaced by that \var{user}'s home directory.
On \UNIX, an initial \samp{\~} is replaced by the environment variable
\envvar{HOME} if it is set; otherwise the current user's home directory
is looked up in the password directory through the built-in module
\refmodule{pwd}\refbimodindex{pwd}.
An initial \samp{\~\var{user}} is looked up directly in the
password directory.
On Windows, only \samp{\~} is supported; it is replaced by the
environment variable \envvar{HOME} or by a combination of
\envvar{HOMEDRIVE} and \envvar{HOMEPATH}.
On Windows, \envvar{HOME} and \envvar{USERPROFILE} will be used if set,
otherwise a combination of \envvar{HOMEPATH} and \envvar{HOMEDRIVE} will be
used. An initial \samp{\~\var{user}} is handled by stripping the last
directory component from the created user path derived above.
If the expansion fails or if the
path does not begin with a tilde, the path is returned unchanged.
@ -81,6 +83,9 @@ of the form \samp{\$\var{name}} or \samp{\$\{\var{name}\}} are
replaced by the value of environment variable \var{name}. Malformed
variable names and references to non-existing variables are left
unchanged.
On Windows, \samp{\%\var{name}\%} expansions are supported in addition to
\samp{\$\var{name}} and \samp{\$\{\var{name}\}}.
\end{funcdesc}
\begin{funcdesc}{getatime}{path}