#! /bin/bash error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code $ROOTCMD usermod -L root exit $error