0

I've written a line in .bashrc

alias untar='sudo tar –xvzf'

Now, when I use "untar" in bash I get the error:

untar filename.tar.gz

tar: invalid option -- '�' Try 'tar --help' or 'tar --usage' for more information.

However when I use the actual command instead of the alias

sudo tar –xvzf filename.tar.gz

It works fine.

I did run . ~/.bashrc, so the alias is "known" (or however you'd call it). Which is also evident form the error message which acknowledges it's a tar command. There's other aliases in bashrc which still work fine.

So, why isn't my alias working?

1 Answers1

4

Your alias has a bad character, not the standard ASCII symbol (minus sign) but another one, which by some fonts is rendered as a longer dash.

This alias works for me

alias untar='sudo tar -xvf'

$ printf '-'|hexdump -C
00000000  2d                                                |-|
00000001
$ printf '–'|hexdump -C
00000000  e2 80 93                                          |...|
00000003
sudodus
  • 46,324
  • 5
  • 88
  • 152
  • Thank you, that solved it. It looked like - but it was not -. It's like the problem with the greek question mark. – Mark Rensen Oct 24 '21 at 12:04
  • You are welcome @MarkRensen. I'm glad that I could spot it: Kudos to the font in my terminal window. – sudodus Oct 24 '21 at 12:06
  • 1
    you should be able to do printf %x\\n "'–" –  Oct 24 '21 at 12:53
  • 1
    printf '%b\n' \\U$(printf '%x\n' "'–") should give you a full circle. –  Oct 24 '21 at 12:55
  • 1
    @bac0n, nicer and simpler commands than mine , but maybe not as good as explanation as with the explicit 'hexdump'. – sudodus Oct 24 '21 at 14:49