hello,
i see, many scripts aren't posix-compatible. you should test all your scripts
in dash. dash is a full posix-compatible-shell and doesn't know any
extensions.
some known mistakes in shell scripts:
# [[ $a = $b ]]
this is bash, not posix. in posix:
# [ "X$a" = "X$b" ]
this 2 X are because $a can include a "-" as first char.
this is a problem in bash too, but nobody thinks about it.
# [ expresion1 ] && [ expression2 ]
faster:
# [ expression1 -a expression2 ]
you can use ( ) too. example:
# [ expression1 -a \( expression2 -o expression3 \) ]
# [ "" = "`grep expr /path/file`" ]
the right way:
# grep -q expr /path/file
you don't need any [ ].
`echo` is the same like $(echo)
# program_that_can_false para1 para2 ...
# if [ $? = 0 ] ; then E1 ; fi
what do you think, how "if" works? right:
# if program_that_can_false para1 para2 ...
# then E1
# fi
and the oposite, if you want to know, if it false:
# if ! program_that_can_false para1 para2 ...
# then E2
# fi
don't forget:
a string can contain whitespaces!
filenames can contain whitespaces too!!!
in /etc/initng somebody can create a file like "oops.i no.i". if you process
something on all i-files, this is a problem:
# files=$(ls /etc/initng)
# for f in ${files} ; do process $f ; done
this won't work!
this is right:
# ls /etc/initng | while read f ; do process "$f" ; done
these >"< are important!
but this won't work if there's a newline in filename. :-/ but this is very,
very rare.
there're many ways to make it wrong. if i see this, i rewrite these lines.
but now i can't rewrite all these many lines.
please think about it and write it right!
thanks
denis knauf
--
_______________________________________________
Initng mailing list
[email protected]
http://jw.dyndns.org/mailman/listinfo/initng