phobos icon indicating copy to clipboard operation
phobos copied to clipboard

Remove std.path.expandTilde

Open dlangBugzillaToGithub opened this issue 2 years ago • 1 comments

witold.baryluk+d (@baryluk) reported this on 2023-03-18T20:06:50Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=23794

Description

Initially, I was thinking: std.path.expandTilde should use HOME env var, not getpwnam_r

This is how most tools use it. Including bash, zsh. Programming languages should not even care.

But that is only when using "~".

If one does "~john" a user database needs to be queried.
 
Using `getpwnam_r` is not just inconsistent with other tools, it also causes now to link to getpwnam_r, which requires dynamic linking, because it pull entire glibc NSS and PAM machinery, preventing static linking.

I would even say more. Remove expandTilde completely from Phobos.

It does not solve anything. When you for example run a binary from bash with tilde, tilde is expanded by bash itself before full path (without tilde) is passed to the binary. Thus supporting tilde rather moot. If one puts a file with tilde into something like a config file (and is read directly by D program), that STILL requires a code to handle this specially, by actually calling expandTilde.

Please remove std.path.expandTilde.

If somebody wants to write the shell itself in D (where supporting ~ would be useful), it should be done in the shell code itself, not standard library.

dlangBugzillaToGithub avatar Mar 18 '23 20:03 dlangBugzillaToGithub