#!/bin/sh

function fn0() {
    echo "fn0 $1"
}

fn1() # Other fn syntax
{
    echo "fn1: Are we really executing this?"
}

function fn2 { # Yet another
    echo fn2
}

function fn3
{ # Yet yet another
    echo fn3
}


fn0

if [ $# -eq 1 ] ; then
	fn1
fi

A=5
while [ $A -gt 0 ] ; do
	A=$(($A - 1))
	echo $A
done 

# Comment
case $# in
    1)
      	echo "1 args"
        ;;
    (2)
      	echo "2 args" ;;# Comment
    'sorry mister')
        echo "This is very much dead code!"
        ;;
    "SORRY")
    	echo "and more of that here"
        ;;
    *)
      	echo "else args $#"
        ;;
esac

for idx in 1 \
    2 \
    3 \
    4 ; do
    echo "IDX: $idx"
done

cat <<EOF
here document
is here
EOF

. `dirname $0`/other.sh

if [ $# -eq 2 ] ; then
	. `dirname $0`/other.sh 5
fi

if [ $# -gt 0 ]
then
	exit $1
fi

A=awk  '{print HEJ}'<<<$0

echo hoppsan

exec 3>&1
exec 4>&2
exec 2>>$1
exec 1>>$1
echo hopp

`dirname $0`/short-test.sh

# Issue #50: This breaks
cat<<EOF || echo "cat failed"
foo
bar
EOF

echo "From here on it do not work!"

`dirname $0`/sh-shebang.sh

# Echo to stderr
>&2 echo "I'm echoing to stderr via some illogical interface"

function some_test
    {
    test "${1}" == "--quiet" &&
        { quiet=${1} ; shift ; echo hej ; }
    }

some_test --quiet

declare -r NIGHTLY_CODE_PROJECT_MASK=$(( 1 << 0 ))
declare -r NIGHTLY_TESTS_PROJECT_MASK=$(( 1 << 1 ))
declare -r NIGHTLY_DOCS_PROJECT_MASK=$(( 1 << 2 ))
echo $((
 1 << 1))

echo $((
 3 << 1
))

let "a = 1 << 3"

echo After

var=(c)
test ${#var[*]} -gt 2 -o \
     "${var[$((${#var[*]} - 1))]}" != "c" ||
    {
    echo Some line
    }
echo Something else


MESSAGE="some message"
USAGE="usage: some message

   --some-option   Does something
"
echo "After usage"