Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

cd without arguments cds to the user's home directory #716

Closed
caseywilliams opened this issue Feb 6, 2020 · 7 comments · Fixed by #746
Closed

cd without arguments cds to the user's home directory #716

caseywilliams opened this issue Feb 6, 2020 · 7 comments · Fixed by #746
Assignees
Labels
bug Something isn't working

Comments

@caseywilliams
Copy link

Describe the Bug

This is not a huge deal, but when I type cd without any arguments, wash cds 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:

  1. wash
  2. cd without arguments
  3. ls

Environment

  • Version: 0.20.1
  • Platform: Ubuntu 18.04
@caseywilliams caseywilliams added the bug Something isn't working label Feb 6, 2020
@MikaelSmith
Copy link
Contributor

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.

@MikaelSmith
Copy link
Contributor

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.

@ekinanp
Copy link
Contributor

ekinanp commented Feb 25, 2020

Hm, if we alias cd, how can we use the old cd? Wouldn't that result in infinite recursion?

@MikaelSmith
Copy link
Contributor

MikaelSmith commented Feb 26, 2020

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.

@MikaelSmith
Copy link
Contributor

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.

@ekinanp
Copy link
Contributor

ekinanp commented Feb 26, 2020

Thank god there's someone on the Wash team that knows shells very well. Sweet, then looks like the alias will work.

@MikaelSmith MikaelSmith self-assigned this Feb 28, 2020
MikaelSmith added a commit to MikaelSmith/wash that referenced this issue Mar 2, 2020
One challenge new users run into is how to get back to Wash's root. Make
`cd` without arguments take them there.

Fixes puppetlabs-toy-chest#716.

Signed-off-by: Michael Smith <[email protected]>
MikaelSmith added a commit to MikaelSmith/wash that referenced this issue Mar 2, 2020
One challenge new users run into is how to get back to Wash's root. Make
`cd` without arguments take them there.

Fixes puppetlabs-toy-chest#716.

Signed-off-by: Michael Smith <[email protected]>
@caseywilliams
Copy link
Author

Thanks both! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants