9

Let's say you leave your terminal open and a co-worker comes along and types:

alias    exit='echo nope'
alias unalias='echo nope'
alias    type='echo nope'
alias builtin='echo nope'
alias   alias='echo nope'

How could you run one of these commands anyway?

Wildcard
  • 35,316
  • 26
  • 130
  • 258
  • 1
    Also (a little later) [Temporarily disabling an alias / quoting a word with a backslash](http://stackoverflow.com/questions/6162903/temporarily-disabling-an-alias-quoting-a-word-with-a-backslash) – Thomas Dickey Mar 30 '16 at 01:25
  • @ThomasDickey, if you can manage to switch it around so my "OP's dupe close button" shows the second link above, I'll accept the dupe close. – Wildcard Mar 30 '16 at 01:29
  • The system allows only one vote, and I cited the earlier one first for the usual reasons (it applies to `bash` as well). – Thomas Dickey Mar 30 '16 at 01:31
  • There's an question about quote part of command name recently, I can not find it yet. – cuonglm Mar 30 '16 at 01:35
  • 1
    @Wildcard the second link can't be used to close this question as a dupe anyway, because it's on stackoverflow.com, not U&L. – cas Mar 30 '16 at 22:39

1 Answers1

16

The method I'm aware of for doing this is to preface the command with a backslash:

$ type type
nope type
$ \type type
type is aliased to `echo nope'
$ unalias type
nope type
$ \type unalias
unalias is aliased to `echo nope'
$ \unalias unalias
$ unalias type
$ type type
type is a shell builtin
$ type unalias
unalias is a shell builtin
$ 

I don't know where this is documented, however.

Wildcard
  • 35,316
  • 26
  • 130
  • 258
  • 2
    The man bash said: The characters /, $, `, and = and any of the shell metacharacters or quoting characters listed above may not appear in an alias name. There are three quoting mechanisms: the escape character, single quotes, and double quotes. – lingceng Jul 16 '19 at 10:44