On all systems I know about, passing a name with no preceding path opens the path relative to the current working directory. However, how reliable is this practice, compared to, for example, always using an absolute path and prepending the result of getenv("HOME")
or getpwuid(getuid())
(see Get home directory in Linux).
Which practice is more standard or reliable or recommended? It is certainly simpler to use the relative path with no preceding /
, as there is no allocating memory to concatenate strings, but what are the downsides to this practice over manually concatenating the absolute path of the home directory?