ammachado commented on code in PR #25072:
URL: https://github.com/apache/camel/pull/25072#discussion_r3645795531


##########
dsl/camel-jbang/camel-launcher/src/jreleaser/bin/lib/publish-state.sh:
##########
@@ -0,0 +1,190 @@
+#!/bin/sh
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# ── publish-state.sh: redacted state-file helpers for publish workflow ──────
+#
+# Simple line-oriented flat-key-value store (one key=value per line).
+# Sourced by camel-publish.sh.  All public functions use $STATE_FILE or 
default.
+
+STATE_FILE="${PUBLISH_STATE_FILE:-}"
+
+__ensure_file() {
+  if [ -z "$STATE_FILE" ]; then
+    STATE_FILE="$(pwd)/target/jreleaser/publish-state.json"
+    mkdir -p "$(dirname "$STATE_FILE")"
+  fi
+}
+
+_is_secret_key() {
+  case "$(echo "$1" | tr '[:lower:]' '[:upper:]')" in
+    *KEY*|*TOKEN*|*SECRET*|*PASS*) return 0 ;;
+    *) return 1 ;;
+  esac
+}
+
+_json_escape() {
+  printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g; s/\t/\\t/g'
+}
+
+_read_val() {
+  _rf="$1"; _rk="$2"
+  [ -f "$_rf" ] || return 0
+  grep "^${_rk}=" "$_rf" 2>/dev/null | head -1 | sed "s|^${_rk}=||"
+}
+
+# ── public API ───────────────────────────────────────────────────────────────
+
+state_get() {
+  _key="$1"
+  __ensure_file; _f="$STATE_FILE"
+
+  if [ ! -f "$_f" ]; then
+    return 1
+  fi
+
+  val="$(_read_val "$_f" "$_key")"
+  # Check if key exists at all (even with empty value)
+  if ! grep -q "^${_key}=" "$_f" 2>/dev/null; then
+    return 1
+  fi
+
+  if _is_secret_key "$_key"; then

Review Comment:
   Fixed in c4b2da24d7e5 — introduced a `_NL` variable holding a literal 
newline (`NL='<newline>'`), and replaced all three `$'\n'` occurrences in 
`state_set` with `${_NL}`. Verified under `dash` that `state_set`/`state_get` 
round-trip correctly with real newline-separated entries.
   
   _Claude Code on behalf of ammachado_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to