Testing functions and position arguments. First is simply that the original positional arguments are preserved. $ cat > test.sh << EOF > echo "\$1 from \$0" > EOF $ sh test.sh hello hello from test.sh $ msh test.sh hello hello from test.sh Next, do they work inside function definitions! $ cat > test.sh << EOF > shout () { > echo \$0 > echo \$1 | tr a-z A-Z > } > shout "hi there" > EOF $ sh test.sh test.sh HI THERE $ msh test.sh test.sh HI THERE Redirection and exit codes should be preserved to just like any other command. $ cat > test.sh << EOF > goodbye () { > echo "eybdoog" > exit \$1 > } > goodbye 0 | rev > goodbye 1 | rev > goodbye 128 > EOF $ sh test.sh goodbye goodbye eybdoog [128] $ msh test.sh goodbye goodbye eybdoog [128] Local variables scopes. $ cat > test.sh << EOF > f () { > local dest > dest="hello from f" > echo \$dest > } > > g () { > local dest > dest="hello from g" > echo \$dest > f > echo \$dest > } > > g > echo "Outer dest: \$dest" > EOF $ sh test.sh hello from g hello from f hello from g Outer dest: $ msh test.sh hello from g hello from f hello from g Outer dest: Local variable scopes from the pipeline position. $ cat > test.sh << EOF > f () { > echo "F: ABC \$ABC DEF \$DEF" > } > g () { > echo "G: ABC \$ABC" > DEF=bar f > echo "G: Env Grep ABC \$(env | grep ABC)" > } > > ABC=foo echo "ABC is \$ABC" > ABC=foo g > ABC=foo env | grep ABC > EOF $ sh test.sh ABC is G: ABC foo F: ABC foo DEF bar G: Env Grep ABC ABC=foo ABC=foo $ msh test.sh ABC is G: ABC foo F: ABC foo DEF bar G: Env Grep ABC ABC=foo ABC=foo