| Start |
|---|
| Whitespace When Assigning Variables Whitespace matters when assigning variables. The first two will result in syntax errors (or worse, executing an incorrect command). The last example will correctly set the variable |
| Failed commands do not stop script execution In most scripting languages, if a function call fails, it may throw an exception and stop execution of the program. Bash commands do not have exceptions, but they do have exit codes. A non-zero exit code signals failure, however, a non-zero exit code will not stop execution of the program. This can lead to dangerous (although admittedly contrived) situations like so: If The best way to deal with this problem is to make use of the set (opens new window) command:
|
| Missing The Last Line in a File The C standard says that files should end with a new line, so if EOF comes at the end of a line, that line may not be missed by some commands. As an example: To make sure this works correctly for in the above example, add a test so that it will continue the loop if the last line is not empty. |
Read Article
https://develop.horje.com/learn/1434/reference