`cd` without arguments `cd`s to the user's home directory
caseywilliams opened this issue · 7 comments
Describe the Bug
This is not a huge deal, but when I type cd
without any arguments, wash cd
s to my user's home directory, where it is unable to list anything:
wash . ❯ cd
wash /home/casey ❯ ls
ls: .: puppetlabs.wash/errored-action: The list action errored on /home/casey: stat /home/casey/.steampath: no such file or directory
this is normal for bash, but seemed odd in the wash context.
Expected Behavior
After typing cd
, I expected to be back in the wash working directory, instead of my user's home directory
Steps to Reproduce
Steps to reproduce the behavior:
wash
cd
without argumentsls
Environment
- Version: 0.20.1
- Platform: Ubuntu 18.04
Yeah, this is a challenge to solve with how we currently setup a shell. #717 will try to make it more obvious what to do when you leave Wash's domain.
One thing we could do is alias cd
so if you run it without arguments, it takes you to Wash's root instead of user root. cd ~
would still take you to user root.
Hm, if we alias cd
, how can we use the old cd
? Wouldn't that result in infinite recursion?
You often see aliases for builtins. You can access the builtin using the command builtin
. Also pretty sure aliases can't recurse. I think they invoke as if they don't exist. They're not functions. But a function (which is what we'd need to implement what I mentioned before) might need to invoke cd
using builtin
.
One-liner for zsh
function cd { if (( $# == 0 )); then builtin cd $W; else builtin cd $*; fi }
Might be slightly different for bash and other shells.
Thank god there's someone on the Wash team that knows shells very well. Sweet, then looks like the alias will work.
Thanks both! :)