#define SQR(x) x*x // bad SQR(9) -> 9*9 // ok SQR(3+2) -> 3+2*3+2 -> 3+6+2 = 11 // wrong #define SQR(x) (x)*(x) // bad 1/SQR(3+2) -> 1/(3+2)*(3+2) -> (1/(3+2))*(3+2) // wrong #define SQR(x) ((x)*(x)) // good 1/SQR(3+2) -> 1/((3+2)*(3+2)) // ok --- $ gcc x.f gcc: error: x.f: Fortran compiler not installed on this system $ chmod 755 x.sh y.sh $ ls -l *.sh -rwxr-xr-x 1 perry perry 15 Sep 12 17:16 x.sh -rwxr-xr-x 1 perry perry 192 Sep 12 17:32 y.sh $ cat x.sh #! /bin/cat hi $ ./x.sh #! /bin/cat hi $ cat y.sh #! /bin/sh echo "hi" # z = 1 # bad x=1 # no blanks in assignment # while test "$x" -lt 7 while [ "$x" -lt 7 ] do echo "$x" x=$((x+1)) done while read line do echo "line = $line" done $ # using dash echo: $ echo "abc\na b c" | dash y.sh hi 1 2 3 4 5 6 line = abc line = a b c $ --- # bash echo is non-standard, needs -e option to interpret backslash-escaped characters: % dash $ echo "a\nb" a b $ bash bash-4.2$ echo "a\nb" a\nb bash-4.2$ echo -e "a\nb" a b bash-4.2$ # portable alternative to shell-specific echo: printf $ printf "a\nb\n" a b $