Remove space after = if trying to assign a value (for empty string, use var='' ... )
4# I want programs to show text in dutch!
5LANGUAGE= nl
6# I want to run the nl command with English error messages!
7LANGUAGE= nl 8
9# SH-1010
10for f in *; do echo "$f" done
Remove space after = if trying to assign a value (for empty string, use var='' ... )
2
3# SH-1007
4# I want programs to show text in dutch!
5LANGUAGE= nl 6# I want to run the nl command with English error messages!
7LANGUAGE= nl
8
Description
Problematic code:
# I want programs to show text in dutch!
LANGUAGE= nl
# I want to run the nl command with English error messages!
LANGUAGE= nl
Correct code:
# I want programs to show text in dutch!
LANGUAGE=nl
# I want to run the nl command with English error messages!
LANGUAGE='' nl
It's easy to think that LANGUAGE= nl
would assign nl
to the variable LANGUAGE
. It doesn't.
Instead, it runs nl
(the number lines
command) and sets LANGUAGE
to an empty string in its environment.
This issue warns about assigning values this way and asks you to be explicit when assigning empty strings (except for IFS
, due to the common IFS= read ..
idiom).
If you're familiar with this behavior and feel that the explicit version is unnecessary, you can ignore this issue.