Skip to content
Vidar Holen edited this page Oct 4, 2015 · 2 revisions

Instead of [ a && b ], use [ a ] && [ b ].

Problematic code:

[ "$1" = "-v" && -z "$2" ]

Correct code:

[ "$1" = "-v" ] && [ -z "$2" ]

Rationale:

&& can not be used in a [ .. ] test expression. Instead, make two [ .. ] expressions and put the && between them.

Exceptions:

None.

Clone this wiki locally