mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-07-31 03:50:32 +02:00
Add another very common shell variable assignment mistake.
This commit is contained in:
@@ -37,7 +37,14 @@ VARIABLE="Some string"
|
|||||||
# But not like this:
|
# But not like this:
|
||||||
VARIABLE = "Some string"
|
VARIABLE = "Some string"
|
||||||
# Bash will decide that VARIABLE is a command it must execute and give an error
|
# Bash will decide that VARIABLE is a command it must execute and give an error
|
||||||
# because it couldn't be found.
|
# because it can't be found.
|
||||||
|
|
||||||
|
# Or like this:
|
||||||
|
Variable= 'Some string'
|
||||||
|
# Bash will decide that 'Some string' is a command it must execute and give an
|
||||||
|
# error because it can't be found. (In this case the 'Variable=' part is seen
|
||||||
|
# as a variable assignment valid only for the scope of the 'Some string'
|
||||||
|
# command.)
|
||||||
|
|
||||||
# Using the variable:
|
# Using the variable:
|
||||||
echo $VARIABLE
|
echo $VARIABLE
|
||||||
|
Reference in New Issue
Block a user