# set_x function - simulates set -x for just the one command

# maybe print a command before executing it
set_x="${set_x:-false}"

# one-liner: set -x; COMMAND; { set +x; } 2>/dev/null
set_x() {
  if [ "${set_x:-false}" = 'true' ]; then
    IFS=" "
    echo "${PS4}$*" 1>&2
  fi
  "$@"
}

# shows same output that `set_x` would show, but doesn't actually run the command
show_x() {
  if [ "${set_x:-false}" = 'true' ]; then
    IFS=" "
    echo "${PS4}$*" 1>&2
  fi
}
