#!/bin/bash

## Copyright (C) 2012 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

if [ "$pv_wrapper_debug" = "true" ]; then
   set -x
fi

true "$0: START"

set -e
set -o nounset
set -o pipefail

trap "error_handler" ERR

error_handler() {
  local exit_code="$?"
  local last_err="$BASH_COMMAND"
  echo "$0: ERROR: BASH_COMMAND '$BASH_COMMAND' exit code '$exit_code'." >&2
}

while read -r line; do
   percent="$line"
   eval $pv_echo_command
   eval $pv_wrapper_command
done

true "$0: END"
