to check where am i going wrong , lastly i copied the script and pasted it
showing this error !
If the variable $rocket_status
contains wither nothing at all or multiple words, then the expansion in [ $rocket_status = "failed" ]
will not make sense to bash
You should put the variable in quotes too
if [ "$rocket_status" = "failed" ]
but in video no quotes are used ?
That may be so in which case the video should get fixed.
This is about the way shell script actually works.
Shell expands all variables first, then looks at the rest of the statement.
Given
if [ $rocket_status = "failed" ]
- If
$rocket_status
variable was empty, then bash would try to evaluate the following
which is an error.if [ = "failed" ]
- If
$rocket_status
variable containedrocket is fine
, then bash would try to evaluate the following
which is also an error - in this case “too many arguments”, as 3 are expected but 5 are present,if [ rocket is fine = "failed" ]
Looking at both cases again, but with the variable enclosed in quotes, they would look like
if [ "" = "failed" ]
if [ "rocket is fine" = "failed" ]
This time both have the expected 3 arguments.