edc / bass

Make Bash utilities usable in Fish shell
MIT License
2.2k stars 70 forks source link

Alias with $* does not get correctly converted #91

Open bentitmus opened 3 years ago

bentitmus commented 3 years ago

For aliases with $* in them, bash will accept the alias. fish complains because these aren't valid in fish. bass should convert these to an acceptable form for fish. Test case:

test.sh:
alias testing='ls $*' -l
$ source test.sh
$ testing .. <Ctrl-Alt-e>
$ ls  -l ..
> bass -d source test.sh
alias "testing"='ls $* -l'- (line 1): $* is not supported. In fish, please use $argv.
function testing --wraps 'ls $* -l' --description 'alias testing=ls $* -l';  ls $* -l $argv; end
...

I believe bash is just silently dropping the $*, although I don't have a lot of experience of bash.

Unfortunately this is in some scripts that I can't change, otherwise I'd just alter the original bash script.

wrzian commented 3 months ago

I was able to fix this with a simple change in the main python file to replace $* with $argv in the copied alias commands, although I assume this is fragile, so do so at your own risk.

You can add this line:

        v = v.replace("$*", "$argv")

to the __bass.py file just before the line with alias_lines.append("alias " + ... (118 for me)

If you installed with oh-my-fish, it should be at ~/.local/share/omf/pkg/bass/functions/__bass.py

ATing the maintainer: @edc, not sure if you would want to merge this change or not, maybe behind a flag. I'll leave that to you.