Question: ❓❓❓

I’m studying the content of this preinst file that the script executes before that package is unpacked from its Debian archive (.deb) file.

The script has the following code:

set -e
# Automatically added by dh_installinit
if [ "$1" = install ]; then
   if [ -d /usr/share/MyApplicationName ]; then
     echo "MyApplicationName is just installed"
     return 1
   rm -Rf $HOME/.config/nautilus-actions/nautilus-actions.conf
   rm -Rf $HOME/.local/share/file-manager/actions/*
# End automatically added section

My first query is about the line:

set -e

I think that the rest of the script is pretty simple: It checks whether the Debian/Ubuntu package manager is executing an install operation. If it is, it checks whether my application has just been installed on the system. If it has, the script prints the message “MyApplicationName is just installed” and ends (return 1 mean that ends with an “error”, doesn’t it?).

If the user is asking the Debian/Ubuntu package system to install my package, the script also deletes two directories.

Is this right or am I missing something?

Good Answer: 👌👌👌

From help set :

  -e  Exit immediately if a command exits with a non-zero status.

But it’s not very reliable and considered as a bad practice, better use :

trap 'do_something' ERR

to run do_something function when errors will occurs.