1 `exit`-ing at the end
- It is true. You're right. Command "exit" is unnecessary .
It doesn't matter in the script, so I left it.
- Privately, I had unnecessary internet links there
The code after the "exit" is not executed.
Later when the script is finished.
I leave the most important links, eg in "--help" or in a comment
and the rest of the unnecessary links I removed .
Off topic:
I also found that inserting code into a function is great to use as a comment.
Code: Select all
new code
COMMENT() {
old code
large amount of old code
}
Useful for me for test new code. In public code, this can be considered littering. ( rubbish / garbage )
In the search engine I found
https://linuxize.com/post/bash-heredoc/
- People often use the exit a lot at the end.
To be sure that the script is finished.
This is more like paranoia.
Fortunately, harmless and I can accept.
---------------
3. Variables named in all capital letters are typically reserved for environment variables. There are a few common approaches, but it mostly is a stylistic choice. My preference is LikeThis.
It depends on the school. ( good practice guides on the Internet )
- Usually simple scripts contain variables made of lowercase letters.
For me, such a code is not readable. Because I don't know if it's a command, variable or function.
- Some tutorials advise us to use variables with uppercase letters.
I am trying to follow this way. For me, such a code is more readable.
When is a function and when is it variable?
If the script is composed from only one file, it is not too big of a problem to find the beginning when it was created and tell.
When a script is composed of many files, this is the problem.
- Sometimes I am trying to give tips in the comments where function is.
- Sometimes I have all functions in file named "functions"
- Sometimes I am trying add name for function something like this
FuncName
or
FUNC_NAME
And "Func" this is short from name "function".
Edited.
Sometimes I use
( inside terminal to find something from scripts )
or
When is a variable from script and when is it environment variables?
- I use environment variables very rarely. If I use it I try to give information in the comment.
- I assume it makes no difference, under certain conditions.
Variables are usually declared in the script.
So I assume that if there is a conflict, the variable in the script overwrites the system variable.
And the problem does not exist.
It is more a mistake when we will
not use
VARIABLE=""
and we will expect the variable to be always empty.
Because if we haven't created it doesn't mean it doesn't exist. ( for example in environment variables )