On Tue, Sep 14, 1999 at 07:58:28PM +0200, Stefan Gybas wrote: > if [ -d /usr/doc/libapache-mod-jserv -a \ > ! /usr/doc/libapache-mod-jserv -ef > /usr/share/doc/libapache-mod-jserv ]; then > > rm -f /usr/doc/libapache-mod-jserv/.dhelp > rmdir --ignore-fail-on-non-empty /usr/doc/libapache-mod-jserv > > if [ -e /usr/doc/libapache-mod-jserv ]; then > cp -ab /usr/doc/libapache-mod-jserv /usr/share/doc > rm -rf /usr/doc/libapache-mod-jserv > fi > > ln -s /usr/share/doc/libapache-mod-jserv /usr/doc > fi
I'd like to propose several changes: [1] Don't specifically look at whether /usr/doc is a directory, that's equivalent to testing for its existence and falls out of some of the more specific tests. [2] Do specifically test whether /usr/doc/libapache-mod-jserv is a directory and is not a symlink. That's the only case where you need to handle specially. [3] Use variables to make the code more readable. [4] be slightly paranoid about your assumptions -- some people run postinst scripts manually, sometimes these scripts die part way through (maybe a disk got full) and have to be restarted. [You don't have to do anything wonderful for these cases -- just not hose anything.] Here's how I'd write the executable part of your sh script fragment: pkg=libapache-mod-jserv old=/usr/doc/$pkg new=/usr/share/doc/$pkg if [ -d $old -a ! -h $old -a ! $old -ef $new ]; then rm -f $old/.dhelp rmdir --ignore-fail-on-non-empty $old if [ -e $old ]; then VERSION_CONTROL=t cp -ab $old $new/.. rm -rf $old fi ln -s $new/$pkg /usr/doc fi I just hope we don't stumble on any more failure modes... -- Raul