[Request] Move "." in PATH to /etc/profile.d
Dear Slackware Maintainers,
I've long been feeling uncomfortable to have the CWD (".") in PATH by default. It has since been my first thing to do after installation to edit "/etc/profile" to remove it. Is there any strong reason to have this, not only confusing, surprising, convention breaking, but also insecure thing not easily configurable in "/etc/profile"? If there is such a strong reason to have it, I apologize for my ignorance. Would it be better to do this, if really necessary, in somewhere like "/etc/profile.d/~.{c,}sh" (\tilde.{c,}sh)? Regards, Guan |
There's a strong reason not to have it appear in $PATH before the usual directories for binaries.
There's a decent reason not to have it appear in $PATH at all for root (we don't). What's the strong reason not to have it appear at all? |
Quote:
As in many (if not most) cases the OS is much less valuable than user data, the same reason for not having it in root's PATH may apply to normal users. |
I can't think of a strong reason not to have it appear at all, but it is questionable whether it is necessary or especially beneficial, and it is sometimes inconvenient to have the current directory in the path.
For example, when using find with execdir, one must edit out the '.' from the path for execdir to work. Code:
PATH=${PATH/.:/} PATH=${PATH%:.} find . -type f -execdir chmod go-rwx {} \; |
Quote:
Quote:
Mostly I was playing devil's advocate. I tend to agree with your point at this juncture where it's become uncommon to have '.' in the $PATH and most people don't expect it, but having it way down towards the end it's not too hazardous since you'd have to be in the same directory as an evil script/binary and also manage to make a typo that matches it while trying to run some other command. I'll consider your advice, though I think the hazard of having it near the end of the $PATH is very slight. |
Whether one prefers "." in ones PATH or not (I prefer not) I don't see what moving that section of code to a member of /etc/profile.d/ would achieve.
BTW, What is this "~.sh" you proposed? It's not a convention I've come across before. |
Quote:
Quote:
Quote:
Quote:
|
How many non-root users actually execute stuff from their cwd?
In my case I occasionally need to execute stuff from the current directory as root (SlackBuilds, nVidia installers etc.), but under a regular user account I usually never run stuff, which isn't in $PATH (including ~/bin). So if something gets executed from '.', it's almost always by accident. Nevertheless thanks for the heads-up, I modified my profile scripts, too. |
Quote:
If you are a developer... you execute things as a normal user all the time. Build.... Test... Fix... Repeat ;) That said, I generally find myself doing ./<whateverIwantTOrun> anyway. |
+1 to move '.' in profile.d
|
EDIT: Removed
|
Quote:
It executes the stable (previous) version, which is already installed as /usr/local/bin/dostuff. Oops! ;) Quote:
|
Quote:
IMO the stock /etc/profile and by extension /etc/profile.d already do far more than I would ideally prefer, and if it were up to me I'd just remove '.' from the PATH and leave individual users to set it in their ~/.profile or equivalent if desired. But if Pat wants to leave it as is for the sake of historical continuity, then I understand that choice also. I've always viewed /etc/profile as something that belongs to the system administrator and the contents of profile.d as belonging to the distro maintainer for stuff that shouldn't need changing. Clearly this isn't the case in slackware as we have things like lang.{c,}sh in profile.d, but IMO that is something that could be improved on. |
Quote:
prefixing the executable with ./ also avoids any unexpected collisions with a shell built-ins or aliases (and bash hash-tables for that matter). IMO relying on "." in your PATH is just too unpredictable. |
Quote:
|
All times are GMT -5. The time now is 02:50 PM. |