Puredyne/Coding Style

< Puredyne

Shell Scripting

This guideline is heavily inspired from the Debian Live Coding Style.

Compatibility

Indenting

Wrapping

  # Bad:
  if foo; then
      bar
  fi

  # Good:
  if foo
  then
      bar
  fi
  #Bad:
  foo () {
      bar
  }

  #Good:
  foo ()
  {
      bar
  }

Variables

  #Bad:
  FOO=bar

  #Good:
  FOO="bar"
  #Bad:
  if [ -f "${FOO}"/foo/"${BAR}"/bar ]
  then
      foobar
  fi

  #Good:
  if [ -f "${FOO}/foo/${BAR}/bar" ]
  then
      foobar
  fi

Miscellaneous

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.