export function kubernetesWatchOneEventShellFunction(): string {
  return [
    "unidesk_watch_one_event() {",
    "  event_file=$(mktemp)",
    "  error_file=$(mktemp)",
    "  set +e",
    "  \"$@\" 2>\"$error_file\" | head -n 1 >\"$event_file\"",
    "  statuses=(\"${PIPESTATUS[@]}\")",
    "  set -e",
    "  watch_status=${statuses[0]:-255}",
    "  case \"$watch_status\" in",
    "    0|141) cat \"$event_file\"; rm -f \"$event_file\" \"$error_file\"; return 0 ;;",
    "    *) cat \"$error_file\" >&2; rm -f \"$event_file\" \"$error_file\"; return \"$watch_status\" ;;",
    "  esac",
    "}",
  ].join("\n");
}
