#Bash

###Scoring

Typically counted in bytes.  Bash programs don't need a trailing newline, so don't count this if your editor adds one automatically.

If your entry only uses builtin features (use `type -a <command>` to find out), then you can claim your entry as **Pure Bash**.  However if your entry calls external binaries (e.g. `paste` from coreutils), then your entry should mention this in the header, e.g. **Bash + coreutils**.

###I/O

Both programs and functions may read from SDTIN and/or use positional command-line parameters `$1`, `$2`, etc (or `$@` for them all).

For testing purposes, you may explicitly put values in the positional parameters using `set -- <param1> <param2> ...`

Output is typically to STDOUT.  Any output to STDERR my be ignored as per standard rules.

###Truthy/Falsey

This is a little odd in shell-type languages.  Shell commands - be they external binaries or shell builtins - return a status code between 0 and 255.  Typically 0 indicates success whereas any other number indicates some error.  The return code can be accessed in the `$?` variable.  For example `grep` returns 0 if it finds a match and 1 if not:

    $ echo haystack | grep -q needle
    $ echo $?
    1
    $ echo haystack | grep -q hay
    $ echo $?
    0
    $ 

The flow control statements (including `if`) use these values accordingly:

    $ if echo haystack | grep -q needle; then echo Found it; fi
    $ if echo haystack | grep -q hay; then echo Found it; fi
    Found it
    $ 

So TRUE = 0, and FALSE = anything else - upside down, right?  You can see this even in the `true` and `false` builtins:

    $ true
    $ echo $?
    0
    $ false
    $ echo $?
    1
    $ 

###Versions

Version 4.0 and later have several more advanced features.  Some that spring to mind:

- Associative arrays
- More expressive brace expansions
- Regex conditionals
- `mapfile`