changeset 696:44a702b32c01

fpkg: include common.subr and use modernized error reporting
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 01 Oct 2024 19:28:57 +0200
parents 5931f16f098f
children fbad4e8e3e42
files sbin/fpkg
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sbin/fpkg	Tue Oct 01 19:01:37 2024 +0200
+++ b/sbin/fpkg	Tue Oct 01 19:28:57 2024 +0200
@@ -103,6 +103,12 @@
   as the host'"'"'s.
 '
 
+
+_p_datadir='@@DATADIR@@'
+[ "${_p_datadir#@@DATADIR}" = '@@' ] && _p_datadir="$(dirname "$0")"/../share/local-bsdtools
+. "${_p_datadir}/common.subr"
+
+
 #:
 #: Configuration directory
 #:
@@ -387,8 +393,7 @@
             exit 2;
             ;;
         *)
-            echo "ERROR: option handling failed" >&2
-            exit 2
+            fatal 2 "option handling failed"
             ;;
     esac
 done
@@ -403,7 +408,7 @@
 command="$1"
 shift
 
-test -n "$command" || { echo "ERROR: no command given" >&2; exit 2; }
+test -n "$command" || fatal 2 "no command given"
 
 case "${command}" in
     audit)
@@ -434,7 +439,6 @@
         command_vv "$@"
         ;;
     *)
-        echo "ERROR: unknown command \`${command}'" >&2
-        exit 2;
+        fatal 2 "unknown command \`${command}'"
         ;;
 esac