Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I really hate writing things in reverse, but a decent style in Bash is to put everything in functions, w/ a main() at the top:

    #! /usr/bin/env bash
    set -e -u
    bar='bar'
    
    main() {
      foofunction
    }
    
    foofunction() {
      echo 'foo'
      echo $bar
    }

    main "$@"


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: