Skip to content

Should rc unset PWD? #109

@kreuter

Description

@kreuter

rc doesn't update PWD the way other shells do; I'm not asking that it do so. However, if an rc process inherits PWD and changes directory, any programs run under rc will inherit an incorrect PWD. I propose that an rc process simply unset PWD when it starts. (But only when it starts, so that a user might maintain PWD in custom cd/pushd/popd functions if they want to.)

Explanation: I have an ancient habit of preferring PWD over getcwd() in programs when I need a pathname for the working directory, because PWD typically contains or derives from previously-supplied user input, while getcwd()'s result can be different from anything the user wants to see or use. (In my programs, such pathnames are usually for diagnostic messages. I should probably always check if the PWD names the same directory as ".", but I'm sure I haven't done so consistently over the years. Anyhow I'd rather the environment variable be unset than incorrect.)

Note: I believe this is orthogonal to whether rc might maintain a $pwd variable, and with what semantics that has. (Drazen Borkovic's fork does this, but it looks like that fork leaves PWD alone, i.e., prone to have a stale value.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions