Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top