Tcl_TildeSubst — C Library Procedures
NAME
Tcl_TildeSubst − replace tilde with home directory in a file name
SYNOPSIS
#include <tcl.h>
char ∗
Tcl_TildeSubst(interp, name)
ARGUMENTS
Tcl_Interp∗interp(in) Interpreter in which to report an error, if any.
char∗name(in) File name, which may start with a “~”.
DESCRIPTION
This utility procedure does tilde substition. If name doesn’t start with a “~” character, then the procedure returns name. If name does start with a tilde, then Tcl_TildeSubst returns a new string identical to name except that the first element of name is replaced with the location of the home directory for the given user. The substitution is carried out in the same way that it would be done by csh. If the tilde is followed immediately by a slash, then the $HOME environment variable is substituted. Otherwise the characters between the tilde and the next slash are taken as a user name, which is looked up in the password file; the user’s home directory is retrieved from the password file and substituted.
The string returned by Tcl_TildeSubst is a static string belonging to Tcl_TildeSubst. Its value will only persist until the next call to Tcl_TildeSubst; the caller should make a copy of the result if it needs to live a long time.
If an error occurs (e.g. because there was no user by the given name) then NULL is returned and an error message will be left at interp->result. It is assumed that interp->result has been initialized in the standard way when Tcl_TildeSubst is invoked.
KEYWORDS
file name, home directory, tilde, user
Sprite version 1.0 —