Empty function in BASH

Posted on Mar 26, 2023

Question

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?

Answer

You could use : that is equivalent to true and is mostly used as do nothing operator...

dummy(){
     : 
  }