Why does the error not appear when there is space before and after "=" in the Bash script?

Asked 5 months ago, Updated 5 months ago, 14 views


when replacing with a Bash script

I wrote = with spaces before and after oo, but the foo was not replaced and the error did not occur.

Using the same description on an interactive bash shell

bash:foo:command not found

It's an error, but why don't you throw up the error in the script?


2022-09-30 11:33

2 Answers

I wrote the variable name foo in the question.

In an environment where there were no errors, the variable name used the name basename as the command. The command not found error did not appear, and it seemed to be treated as a variable with a blank string after the substitute line.

I have posted an answer to close the question, although it contains information that was not included in the question.

2022-09-30 11:33

I don't need any space when I replace it with bash.Run line by line, so if you write foo="bar", you execute the foot command, where = and "bar" are arguments.Without the foo command, the command not found error appears.
It looks like ls-la./.If ls is changed to sdfsdfsdf, sdfsdf-la. / Same, command not found error should appear.

2022-09-30 11:33

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.