LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Finding bugs in bash scripts, Analyis tool for bash (https://www.linuxquestions.org/questions/programming-9/finding-bugs-in-bash-scripts-analyis-tool-for-bash-765803/)

traene 10-31-2009 10:35 AM

Finding bugs in bash scripts, Analyis tool for bash
 
Is there a tool available to verify shell scripts? As an example for other languages like Java there exist some nice tools to integrate into eclipse(, like PMD). Source code analysis

The Java compiler itself checks for several issues.

They find 'patterns of errors' which should be avoided, something like:
- obsolete API call used
- return value not used
- etc.

gnashley 10-31-2009 11:06 AM

The bash debugger:
http://bashdb.sourceforge.net/

tuxdev 10-31-2009 11:42 AM

I use this to sanitize the environment:
Code:

  source "/etc/profile" > /dev/null
  set -eu
  shopt -s nullglob dotglob
  IFS=$'\n\t'
  umask 022
  unalias -a
  unset -f $(declare -F | sed "s/^declare -f //")

set -eu is a huge step towards writing reliable and robust bash scripts by using the "fail fast" approach.


All times are GMT -5. The time now is 12:09 PM.