escaping bash 'test' keywork in a bash script

1.3k views Asked by At

I have a bash script that needs to run this command:

python manage.py test

But since test is a bash command by itself, I need to escape it somehow. but couldn't found out how.

any leads? or maybe I'm worrying for nothing?

1

There are 1 answers

0
Mechanical snail On BEST ANSWER

test is a Bash builtin command, not a keyword or reserved word. This means Bash will only interpret it if it is the first token in a command, like

test blah

In

python manage.py test

Bash will just pass it as a parameter to python (that is, it will execute python with two parameters, manage.py and test); you don't need to escape it.

In general, Bash doesn't have reserved words in the sense of C-like languages. The only things you need to escape are whitespace (which Bash uses to separate params), and certain symbols including $(&|; which Bash uses for its variables and command separators.