There is zero coverage of the code related to the $pwd variable but there is a comment saying it should be deprecated:
https://github.com/elves/elvish/blob/ac4ac7f4479140efb4dd0134d6b4ff505632e17c/pkg/eval/pwd.go#L19-L26
Should it actually be deprecated or that comment removed and tests added?
P.S., If we end up keeping $pwd the documentation needs some leading whitespace in the $pwd example.
Perhaps we should just have a built-in wrapped around os.Getwd? Possibly in the proposed path: module or maybe in a future module with other wrappers around the os package.
@kolbycrouch, Yes, it certainly feels like there should be a builtin pwd command regardless of whether the $pwd var is retained. If for no other reason than people used to POSIX shells expect it to be a shell builtin.
Regarding the original question I would only be in favor of removing this var if there is a different lightweight mechanism for temporarily switching directories. In other words it should be possible to do something like
cd /tmp; some_cmd; cd -
rather than
prev_cwd=(pwd); cd /tmp; some_cmd; cd $prev_cwd
The $pwd var makes that as easy as pwd=/tmp some_cmd.
I personally use $pwd quite frequently, and I think pwd=/foo some_command is quite an elegant way of temporarily changing directory. I would vote for keeping it.
The current pwd variable is also a good semantic match to unix:umask.
Most helpful comment
I personally use
$pwdquite frequently, and I thinkpwd=/foo some_commandis quite an elegant way of temporarily changing directory. I would vote for keeping it.