Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cd does not work if a directory starts with the character - #6071

Closed
bugnano opened this issue Aug 26, 2019 · 3 comments
Closed

cd does not work if a directory starts with the character - #6071

bugnano opened this issue Aug 26, 2019 · 3 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@bugnano
Copy link

bugnano commented Aug 26, 2019

I'm using fish version 2.7.1 running on Fedora 29 x86_64.
Let's say for example that I create a directory like this:

mkdir -- -mydirectory

this creates a directory called -mydirectory (note that its name begins with the - character)

now I want to go to that directory.

If I try to run:

cd -mydirectory

it fails with:

cd: Unknown option '-mydirectory/'
/usr/share/fish/functions/cd.fish (line 30): 
    builtin cd $argv
    ^
in function 'cd'
	called on standard input
	with parameter list '-mydirectory/'

ok, let's try with:

cd -- -mydirectory

and it fails with the error:

Too many args for cd command

So I don't know any other method to cd to that directory

@Darkshadow2
Copy link
Contributor

I see this also in current master.

For the second case, the cd function tests if there's more than one argument and prints Too many args for cd command if there is.

@bugnano As a workaround, you can use builtin cd -- -mydirectory and it'll work, but prevd and nextd won't work right, as the cd function sets those up.

@zanchey
Copy link
Member

zanchey commented Aug 27, 2019

You can also use cd ./-mydirectory, which makes nextd and prevd work.

Probably the cd function should be converted to argparse.

@zanchey zanchey added this to the fish-future milestone Aug 27, 2019
@zanchey zanchey added the bug Something that's not working as intended label Aug 27, 2019
@zanchey zanchey modified the milestones: fish-future, fish 3.1.0 Oct 17, 2019
@zanchey
Copy link
Member

zanchey commented Oct 17, 2019

Fixed in 2e6ab0b.

@zanchey zanchey closed this as completed Oct 17, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

3 participants