I'm using FPM tool to create .deb package. This tool create before/after remove package from supported files.
Unfortunatly the bash script generated by FPM contains such function
dummy() {
}
And this script exit with an error:
Syntax error: "}" unexpected
Does BASH doesn't allow empty functions? Which version of bash/linux have this limitation?
To find out if a bash variable is empty: Return true if a bash variable is unset or set to the empty string: if [ -z "$var" ]; Another option: [ -z "$var" ] && echo "Empty" Determine if a bash variable is empty: [[ !
The $0 special variable can be used in the terminal to print the name of your current shell simply by executing the following statement: $ echo $0.
A bash function is a method used in shell scripts to group reusable code blocks. This feature is available for most programming languages, known under different names such as procedures, methods, or subroutines.
bash [filename] runs the commands saved in a file. $@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.
You could use :
that is equivalent to true
and is mostly used
as do nothing operator...
dummy(){
:
}
A one liner
dummy(){ :; }
:
is the null command
;
is needed in the one line format
An empty bash function may be illegal. function contains only comments will be considered to be empty too.
a ":" (null command) can be placed in function if you want to "DO NOTHING"
see: http://tldp.org/LDP/abs/html/functions.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With