From: Lionel B. <lio...@bo...> - 2005-02-15 09:50:15
|
Michel Bouissou wrote the following on 15.02.2005 07:57 : >Le Lundi 14 F=E9vrier 2005 23:40, Lionel Bouton a =E9crit : > =20 > >> - update_sqlgrey_whitelists doesn't rely on mktemp's '-t' parameter >>anymore. >> =20 >> > >By the way, I find 2 issues in update_sqlgrey_whitelists : > >1/ The result code or variable existence for mktemp is not tested : > ># Go into a temp directory >MYTMP=3D`mktemp -dt sqlgrey.XXXXXX` >cd $MYTMP > >I would prefer : > ># Go into a temp directory >MYTMP=3D`mktemp -dt sqlgrey.XXXXXX` >[ -n "$MYTMP" -a -d "$MYTMP" ] && cd $MYTMP || { > echo "Error creating temporary directory; > exit 1 >} > > =20 > Took it. >2/ This frightens me (afraid of cd /; rm -rf * ;-) especially because of= (1)=20 >above: > ># Setup a clean exit >clean_exit() { > cd / > rm -rf $MYTMP > exit $1 >} > >I would very much prefer something like: > ># Setup a clean exit >clean_exit() { > cd ~sqlgrey > [ -n "$MYTMP" -a -d "$MYTMP" ] && rm -rf $MYTMP > exit $1 >} > > =20 > Shouldn't be a problem (MYTMP can't be '/' or something approaching) ,=20 but cd ~sqlgrey is better. The test before rm -rf shouldn't be needed now but might come handy if=20 clean_exit can be called before we make sure MYTMP is a real directory. Took it too. Thanks. Lionel |