DEV Community

Discussion on: Shell Scripts Matter

Collapse
 
vosikwemhe profile image
Victory Osikwemhe

i don't always use the trap builtin command, but i will start using it in my script. You should have made provision for type checking using the type builtin command.

for example to check if a command is a function or an alias


    s() {
       printf "bash is good\n"
    }

    checkType=$(type -t s)

   [[ "$s" != "function" ]] && {
      printf "$s is not a function"
      exit 1 
   }

Enter fullscreen mode Exit fullscreen mode