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

wrong alias definition when command contains a metacharacter (like "+" or backslash) #8720

Closed
Dieken opened this issue Feb 12, 2022 · 4 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@Dieken
Copy link

Dieken commented Feb 12, 2022

fish 3.3.1, macOS Monterey, 12.0.1

$ alias g++ 'grc g++'

$ alias | fgrep g++
alias g++ 'g++ grc g++'

$ alias 'g\+\+' 'grc g++'

$ alias | fgrep g++
alias g++ g\\\\+\\\\+\\\ grc\\\ g++
@faho
Copy link
Member

faho commented Feb 12, 2022

The only thing broken here is alias display.

The actual function definition is correct. See type g++.

@faho faho added the bug Something that's not working as intended label Feb 12, 2022
@faho faho added this to the fish-future milestone Feb 12, 2022
@Dieken
Copy link
Author

Dieken commented Feb 13, 2022

Thanks for your confirmation!

Another minor issue, in bash and zsh, I can use alias xxx to get alias definition, could fish support this too? Currently I have to use alias | string match “alias xxx *”.

@faho
Copy link
Member

faho commented Feb 13, 2022

Fish does not, in a very real sense, have aliases. alias is a function that defines functions.

You can just use functions xxx.

@Dieken
Copy link
Author

Dieken commented Feb 13, 2022

You are right, fish alias is actually function.

$ alias
alias cp 'cp -i'
...

$ functions cp
# Defined in /Users/liuyb/.config/fish/functions/cp.fish @ line 2
function cp --description 'alias cp cp -i'
 command cp -i $argv; 
end

$ function xxx --description 'alias xxx yyy'; echo yyy; end

$ alias | grep xxx
alias xxx yyy

It's inconvenient to parse the output of functions cp for "cp -i", so I would like to have an alias cp that just outputs single alias definition in single line.

@faho faho changed the title wrong alias definition when command contains "+" wrong alias definition when command contains a metacharacter (like "+" or backslash) Jun 17, 2023
@faho faho closed this as completed in 38ac21b Jun 17, 2023
@faho faho modified the milestones: fish-future, fish 3.6.2 Jun 17, 2023
faho added a commit that referenced this issue Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

2 participants