Skip to content

Commit 345af53

Browse files
committed
style(cli): use printf in graph-query check
Gemini review flagged the remaining echo calls in the graph-query check. printf avoids echo option and escape handling when printing captured command output such as create_output, restart_output, and read_output. Validation: - nixfmt modules/_checks/cli-graph-query.nix - nix build .#checks.x86_64-linux.logseq-cli-graph-query - git diff --check - nix build .#checks.x86_64-linux.pre-commit-check
1 parent 4f511b3 commit 345af53

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

modules/_checks/cli-graph-query.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pkgs.runCommand "logseq-cli-graph-query-check" { } ''
2727
query="[:find ?content :where [?b :block/title ?content] [(clojure.string/includes? ?content \"$marker\")]]"
2828
2929
fail() {
30-
echo "$1" >&2
30+
printf '%s\n' "$1" >&2
3131
printf '%s\n' "$2" >&2
3232
exit 1
3333
}
@@ -38,7 +38,7 @@ pkgs.runCommand "logseq-cli-graph-query-check" { } ''
3838
[ "$create_status" -eq 0 ] || fail "logseq-cli graph create exited $create_status" "$create_output"
3939
# server-start-timeout-orphan is upstream's worker-boot failure symptom; treat
4040
# it as failure even if the exit code is swallowed.
41-
if echo "$create_output" | ${pkgs.gnugrep}/bin/grep -qF 'server-start-timeout-orphan'; then
41+
if printf '%s\n' "$create_output" | ${pkgs.gnugrep}/bin/grep -qF 'server-start-timeout-orphan'; then
4242
fail "logseq-cli db-worker failed to start during graph create (server-start-timeout-orphan)" "$create_output"
4343
fi
4444
@@ -48,7 +48,7 @@ pkgs.runCommand "logseq-cli-graph-query-check" { } ''
4848
pre_status=0
4949
pre_output=$(${cli}/bin/logseq-cli query -g probe --root-dir "$graph_root" -o json --query "$query" 2>&1) || pre_status=$?
5050
[ "$pre_status" -eq 0 ] || fail "logseq-cli pre-write control query exited $pre_status" "$pre_output"
51-
if ! echo "$pre_output" | ${pkgs.gnugrep}/bin/grep -qF '"result":[]'; then
51+
if ! printf '%s\n' "$pre_output" | ${pkgs.gnugrep}/bin/grep -qF '"result":[]'; then
5252
fail "pre-write control query returned a non-empty result (marker leaked or query does not filter)" "$pre_output"
5353
fi
5454
@@ -63,7 +63,7 @@ pkgs.runCommand "logseq-cli-graph-query-check" { } ''
6363
restart_status=0
6464
restart_output=$(${cli}/bin/logseq-cli server restart -g probe --root-dir "$graph_root" 2>&1) || restart_status=$?
6565
[ "$restart_status" -eq 0 ] || fail "logseq-cli server restart exited $restart_status" "$restart_output"
66-
if echo "$restart_output" | ${pkgs.gnugrep}/bin/grep -qF 'server-start-timeout-orphan'; then
66+
if printf '%s\n' "$restart_output" | ${pkgs.gnugrep}/bin/grep -qF 'server-start-timeout-orphan'; then
6767
fail "logseq-cli db-worker failed to restart before read-back (server-start-timeout-orphan)" "$restart_output"
6868
fi
6969
@@ -72,10 +72,10 @@ pkgs.runCommand "logseq-cli-graph-query-check" { } ''
7272
read_status=0
7373
read_output=$(${cli}/bin/logseq-cli query -g probe --root-dir "$graph_root" -o json --query "$query" 2>&1) || read_status=$?
7474
[ "$read_status" -eq 0 ] || fail "logseq-cli read-back query exited $read_status" "$read_output"
75-
if ! echo "$read_output" | ${pkgs.gnugrep}/bin/grep -qF '"status":"ok"'; then
75+
if ! printf '%s\n' "$read_output" | ${pkgs.gnugrep}/bin/grep -qF '"status":"ok"'; then
7676
fail "read-back query did not report status ok" "$read_output"
7777
fi
78-
if ! echo "$read_output" | ${pkgs.gnugrep}/bin/grep -qF "$marker"; then
78+
if ! printf '%s\n' "$read_output" | ${pkgs.gnugrep}/bin/grep -qF "$marker"; then
7979
fail "read-back query did not return the marker block; sqlite-wasm round-trip failed" "$read_output"
8080
fi
8181

0 commit comments

Comments
 (0)