Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • regarding relative paths: what about having a '-r' switch, which would add the path without making it absolute first, and which would also look for it as absolute before adding it? If this were script, one could use it in other shells. Is there any benefit of having it as a function? nice code! Commented Jun 10, 2019 at 6:23
  • 1
    @hoijui It has to be a function because it's modifying the current environment. If it were a script, it would modify the environment of the subprocess running the script and, when the script exited you'd have the same $PATH as you had before. As for -r, no, I think that relative paths in $PATH are just too unreliable and weird (your path changes every time you cd!) to want to support something like that in a general tool. Commented Jun 10, 2019 at 10:15