#!/bin/bash
# Structural cases (2026-10-27 redesign): the gate judges by positive evidence of a send,
# reads the scripts it can reach, and judges `bash -c` / quoted text / direct execution.
# Fixtures are written to a temp dir so the command lines themselves stay innocuous.
H="${H:-$HOME/.claude/hooks/email-send-gate.sh}"
# Test runs never append to the real gate log: the judge honours EMAIL_GATE_LOG.
if [ -z "${EMAIL_GATE_LOG:-}" ]; then EMAIL_GATE_LOG=$(mktemp /tmp/email-gate-test-log.XXXXXX); _GATE_LOG_TMP=1; fi; export EMAIL_GATE_LOG
pass=0; fail=0
check() {
  local got; got=$(printf '%s' "$3" | "$H")
  local dec="allow"
  case "$got" in *'"permissionDecision":"ask"'*) dec=ask;; *'"permissionDecision":"deny"'*) dec=deny;; esac
  if [ "$dec" = "$2" ]; then pass=$((pass+1)); echo "ok    $1 -> $dec"; else fail=$((fail+1)); echo "FAIL  $1 -> $dec (expected $2)"; echo "      $got" | head -c 500; echo; fi
}
T=$(mktemp -d /tmp/gate-fixtures.XXXXXX)
trap 'rm -rf "$T"' EXIT
mkdir -p "$T/lib"

# --- fixtures -----------------------------------------------------------------
# A script whose NAME carries a sending token but whose code only reads.
cat > "$T/mailer-check.mjs" <<'EOF'
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { helper } from './lib/clean.mjs';
const rows = JSON.parse(readFileSync(join(process.cwd(), 'ledger.json'), 'utf8'));
console.log(helper(rows.length), 'leads; mailer-daemon rows skipped');
EOF
cat > "$T/lib/clean.mjs" <<'EOF'
export function helper(n) { return `${n} rows`; }
EOF
# An innocuously named script that sends through Apple Mail from inside JS.
cat > "$T/bump.mjs" <<'EOF'
import { execFileSync } from 'node:child_process';
const script = `tell application "Mail"
  set m to make new outgoing message with properties {sender:"Oren Magid <oren@orenmagid.com>", subject:"Nudge"}
  make new to recipient at end of to recipients of m with properties {address:"lead@example.com"}
  send m
end tell`;
execFileSync('osascript', ['-e', script]);
EOF
# nodemailer with literal from/to.
cat > "$T/notify.mjs" <<'EOF'
import nodemailer from 'nodemailer';
const t = nodemailer.createTransport({ host: 'smtp.example.com' });
await t.sendMail({ from: 'oren@orenmagid.com', to: 'a@b.com', subject: 'Status' });
EOF
# Name token + a third-party package the gate cannot inspect, no evidence → heuristics apply.
cat > "$T/send-report.mjs" <<'EOF'
import YAML from 'yaml';
console.log(YAML.stringify({ ok: true }));
EOF
# Evidence two imports deep: raw SMTP verbs in a local module.
cat > "$T/chain.mjs" <<'EOF'
import { go } from './lib/out.mjs';
go();
EOF
cat > "$T/lib/out.mjs" <<'EOF'
import net from 'node:net';
export function go() { const s = net.connect(25, 'mx.example.com'); s.write('MAIL FROM:<oren@orenmagid.com>\r\nRCPT TO:<a@b.com>\r\n'); }
EOF
# Python: smtplib vs a clean script with a sending token in its name.
cat > "$T/report.py" <<'EOF'
import smtplib, json
s = smtplib.SMTP('smtp.example.com'); s.sendmail('oren@orenmagid.com', ['a@b.com'], 'hi')
EOF
cat > "$T/send_stats.py" <<'EOF'
import json, os, sys
print(json.dumps({"n": len(os.listdir("."))}))
EOF
# Import cycle, both clean.
cat > "$T/cycle-a.mjs" <<'EOF'
import './cycle-b.mjs';
console.log('a');
EOF
cat > "$T/cycle-b.mjs" <<'EOF'
import './cycle-a.mjs';
console.log('b');
EOF
# AppleScript files: draft-only; send with literal sender + recipient from argv; send without sender.
cat > "$T/draft.applescript" <<'EOF'
-- opens a reply draft; Oren sends from the window (never by script: send all from oren@)
on run argv
  tell application "Mail"
    set r to reply (item 1 of messages of inbox) with opening window
    set sender of r to "Oren Magid <oren@orenmagid.com>"
    make new to recipient at end of to recipients of r with properties {address:(item 1 of argv)}
  end tell
end run
EOF
cat > "$T/sendit.applescript" <<'EOF'
on run argv
  tell application "Mail"
    set m to make new outgoing message with properties {sender:"Oren Magid <oren@orenmagid.com>", subject:"Follow-up"}
    make new to recipient at end of to recipients of m with properties {address:(item 1 of argv)}
    send m
  end tell
end run
EOF
cat > "$T/nosender.applescript" <<'EOF'
tell application "Mail"
  set m to make new outgoing message with properties {subject:"x"}
  make new to recipient at end of to recipients of m with properties {address:"a@b.com"}
  send m
end tell
EOF
# Shell scripts run directly: one sends, one (with a sending token in its name) only lists.
cat > "$T/run.sh" <<'EOF'
#!/bin/bash
echo hi | sendmail x@y.com
EOF
cat > "$T/send-report.sh" <<'EOF'
#!/bin/bash
# nothing here sends; the word sendmail in this comment is not a command
ls -la "$HOME"
EOF
chmod +x "$T/run.sh" "$T/send-report.sh"
# A script that calls osascript on a file the gate cannot find → opaque, no name token → allow (as before).
cat > "$T/opaque.mjs" <<'EOF'
import { execFileSync } from 'node:child_process';
execFileSync('osascript', [process.argv[2]]);
EOF
# Mail/send words that only ever sit inside quoted payloads (a test runner) vs a script that runs osascript.
cat > "$T/payloads.sh" <<'EOF'
#!/bin/bash
# a test runner: Mail/send text only ever appears inside quoted payloads, never run
P='{"command":"osascript -e \"tell application \\\"Mail\\\"\" -e \"send m\""}'
printf '%s' "$P" | wc -c
EOF
cat > "$T/really-sends.sh" <<'EOF'
#!/bin/bash
osascript -e 'tell application "Mail"' -e 'set m to make new outgoing message with properties {sender:"Oren Magid <oren@orenmagid.com>", subject:"x"}' -e 'make new to recipient at end of to recipients of m with properties {address:"a@b.com"}' -e 'send m' -e 'end tell'
EOF
chmod +x "$T/payloads.sh" "$T/really-sends.sh"
# From the adversarial review (2026-10-27): a node script reaching its AppleScript by a template-literal path.
cat > "$T/bump2.mjs" <<'EOF'
import { execFileSync } from 'node:child_process';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const HERE = dirname(fileURLToPath(import.meta.url));
execFileSync('osascript', [`${HERE}/sendit.applescript`, process.argv[2]]);
EOF
cat > "$T/clean.mjs" <<'EOF'
console.log('preload');
EOF
cat > "$T/draft-with-comment.applescript" <<'EOF'
tell application "Mail"
  set m to make new outgoing message with properties {subject:"x", visible:true}
  -- leave the window open; Oren will send
  save m
end tell
EOF

DESC_LEAD='"description":"Send email from oren@orenmagid.com to lead@example.com, subject \"Nudge\""'
DESC_AB='"description":"Send email from oren@orenmagid.com to a@b.com, subject \"Status\""'
DESC_FU='"description":"Send email from oren@orenmagid.com to lead@example.com, subject \"Follow-up\""'

# --- certified read-only beats the name rule -----------------------------------
check "name-token-but-clean-code-is-certified" allow '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"check","command":"node '"$T"'/mailer-check.mjs"}}'
check "python-send-token-name-clean-code" allow '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"stats","command":"python3 '"$T"'/send_stats.py"}}'
check "direct-exec-send-token-name-clean-sh" allow '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"list","command":"'"$T"'/send-report.sh"}}'
check "import-cycle-terminates" allow '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"run","command":"node '"$T"'/cycle-a.mjs"}}'
check "relative-path-after-cd" allow '{"tool_name":"Bash","cwd":"/","tool_input":{"description":"check","command":"cd '"$T"' && node mailer-check.mjs"}}'
check "real-bump-drafts-list-is-not-a-send" allow '{"tool_name":"Bash","cwd":"/Users/orenmagid/flow","tool_input":{"description":"list due bumps","command":"node ~/flow/scripts/prospects/bump-drafts.mjs --list"}}'
check "applescript-draft-only-file" allow '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"open draft","command":"osascript '"$T"'/draft.applescript lead@example.com"}}'
check "script-running-osascript-on-unseen-file-is-asked" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"run","command":"node '"$T"'/opaque.mjs ~/x.scpt"}}'
check "variable-path-no-crash-no-token" allow '{"tool_name":"Bash","cwd":"/","tool_input":{"description":"list","command":"cd ~/flow && S=scripts/prospects && node \"$S/bump-drafts.mjs\" --list"}}'

check "sh-with-mail-words-only-in-payloads" allow '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"run tests","command":"bash '"$T"'/payloads.sh"}}'
check "sh-that-runs-osascript-send" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"run","command":"bash '"$T"'/really-sends.sh"}}'
check "writing-an-applescript-file-is-not-a-send" allow '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"write script","command":"cat > '"$T"'/new.applescript <<'"'"'EOF'"'"'\ntell application \"Mail\"\n set m to make new outgoing message\n send m\nend tell\nEOF"}}'
check "gate-test-runner-unquoted" allow '{"tool_name":"Bash","cwd":"/Users/orenmagid","tool_input":{"description":"run gate tests","command":"bash ~/.claude/hooks/tests/email-send-gate.test.sh"}}'

# --- positive evidence inside code beats an innocent name ----------------------
check "innocent-name-apple-send-inside-no-desc" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"nudge the lead","command":"node '"$T"'/bump.mjs"}}'
check "innocent-name-apple-send-inside+desc" ask '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{'"$DESC_LEAD"',"command":"node '"$T"'/bump.mjs"}}'
check "innocent-name-apple-send-wrong-desc" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"Send email from oren.michael.magid@gmail.com to lead@example.com, subject \"Nudge\"","command":"node '"$T"'/bump.mjs"}}'
check "nodemailer-no-desc" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"notify","command":"node '"$T"'/notify.mjs"}}'
check "nodemailer+desc" ask '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{'"$DESC_AB"',"command":"node '"$T"'/notify.mjs"}}'
check "evidence-two-imports-deep" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"run","command":"node '"$T"'/chain.mjs"}}'
check "python-smtplib" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"report","command":"python3 '"$T"'/report.py"}}'
check "direct-exec-sh-with-sendmail" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"run","command":"'"$T"'/run.sh"}}'
check "applescript-file-send-recipient-from-argv-no-desc" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"follow up","command":"osascript '"$T"'/sendit.applescript lead@example.com"}}'
check "applescript-file-send-recipient-from-argv+desc" ask '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{'"$DESC_FU"',"command":"osascript '"$T"'/sendit.applescript lead@example.com"}}'
check "applescript-file-send-no-sender" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"Send email from oren@orenmagid.com to a@b.com, subject \"x\"","command":"osascript '"$T"'/nosender.applescript"}}'
osacompile -o "$T/sendit.scpt" "$T/sendit.applescript" 2>/dev/null
check "compiled-scpt-send-no-desc" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"follow up","command":"osascript '"$T"'/sendit.scpt lead@example.com"}}'
check "compiled-scpt-send+desc" ask '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{'"$DESC_FU"',"command":"osascript '"$T"'/sendit.scpt lead@example.com"}}'
check "heredoc-written-then-run-with-mailer" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"notify","command":"cat > '"$T"'/w.mjs <<'"'"'EOF'"'"'\nimport nodemailer from \"nodemailer\";\nawait nodemailer.createTransport({}).sendMail({from: \"oren@orenmagid.com\", to: \"a@b.com\"});\nEOF\nnode '"$T"'/w.mjs"}}'
check "stdin-heredoc-script-with-mailer" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"notify","command":"node - <<'"'"'JS'"'"'\nimport nodemailer from \"nodemailer\";\nawait nodemailer.createTransport({}).sendMail({from: \"oren@orenmagid.com\", to: \"a@b.com\"});\nJS"}}'
check "jxa-inline-send-no-desc" deny '{"tool_name":"Bash","tool_input":{"description":"send","command":"osascript -l JavaScript -e '"'"'const Mail = Application(\"Mail\"); const m = Mail.OutgoingMessage({sender: \"Oren Magid <oren@orenmagid.com>\", subject: \"x\"}); Mail.outgoingMessages.push(m); m.toRecipients.push(Mail.Recipient({address: \"a@b.com\"})); m.send()'"'"'"}}'
check "jxa-inline-send+desc" ask '{"tool_name":"Bash","tool_input":{"description":"Send email from oren@orenmagid.com to a@b.com, subject \"x\"","command":"osascript -l JavaScript -e '"'"'const Mail = Application(\"Mail\"); const m = Mail.OutgoingMessage({sender: \"Oren Magid <oren@orenmagid.com>\", subject: \"x\"}); Mail.outgoingMessages.push(m); m.toRecipients.push(Mail.Recipient({address: \"a@b.com\"})); m.send()'"'"'"}}'

# --- shapes from the adversarial review (2026-10-27) ------------------------------
check "node-template-literal-path-to-applescript-send" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"nudge","command":"node '"$T"'/bump2.mjs lead@example.com"}}'
check "osascript-stdin-redirect-from-file" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"run","command":"osascript < '"$T"'/sendit.applescript"}}'
check "cat-pipe-osascript" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"run","command":"cat '"$T"'/sendit.applescript | osascript"}}'
check "cat-pipe-osascript-dash" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"run","command":"cat '"$T"'/sendit.applescript | osascript - lead@example.com"}}'
check "osascript-unknown-stdin" deny '{"tool_name":"Bash","tool_input":{"description":"run","command":"some-generator | osascript"}}'
check "tell-app-short-name-reply-shape" deny '{"tool_name":"Bash","tool_input":{"description":"reply","command":"osascript -e '"'"'tell app \"Mail\"'"'"' -e '"'"'set r to reply (item 1 of messages of inbox) with opening window'"'"' -e '"'"'set sender of r to \"Oren Magid <oren@orenmagid.com>\"'"'"' -e '"'"'make new to recipient at end of to recipients of r with properties {address:\"a@b.com\"}'"'"' -e '"'"'send r'"'"' -e '"'"'end tell'"'"'"}}'
check "tell-application-mail-dot-app" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"osascript -e '"'"'tell application \"Mail.app\" to send (first item of outgoing messages)'"'"'"}}'
check "send-with-trailing-comment" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"osascript -e '"'"'tell application \"Mail\"'"'"' -e '"'"'send m -- go'"'"' -e '"'"'end tell'"'"'"}}'
check "inline-recipient-from-argv+desc" ask '{"tool_name":"Bash","tool_input":{'"$DESC_FU"',"command":"osascript -e '"'"'on run argv'"'"' -e '"'"'tell application \"Mail\"'"'"' -e '"'"'set m to make new outgoing message with properties {sender:\"Oren Magid <oren@orenmagid.com>\", subject:\"Follow-up\"}'"'"' -e '"'"'make new to recipient at end of to recipients of m with properties {address:(item 1 of argv)}'"'"' -e '"'"'send m'"'"' -e '"'"'end tell'"'"' -e '"'"'end run'"'"' lead@example.com"}}'
check "jxa-Mail-send-with-argument" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"osascript -l JavaScript -e '"'"'const Mail = Application(\"com.apple.mail\"); const m = Mail.OutgoingMessage({sender: \"Oren <oren@orenmagid.com>\"}); Mail.outgoingMessages.push(m); Mail.send(m)'"'"'"}}'
check "curl-gmail-api-send" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"curl -s -X POST https://gmail.googleapis.com/gmail/v1/users/me/messages/send -H \"Authorization: Bearer $TOKEN\" -d @msg.json"}}'
check "curl-resend-api" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"curl -X POST https://api.resend.com/emails -H \"Authorization: Bearer re_x\" -d @body.json"}}'
check "echo-redirect-then-run" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"x","command":"echo '"'"'echo hi | sendmail lead@example.com'"'"' > '"$T"'/later.sh && bash '"$T"'/later.sh"}}'
check "source-a-sending-script" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"x","command":"source '"$T"'/run.sh"}}'
check "dot-source-a-sending-script" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"x","command":". '"$T"'/run.sh"}}'
check "eval-a-cli-send" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"eval '"'"'echo hi | sendmail x@y.com'"'"'"}}'
check "mail-to-address-without-s" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"mail lead@example.com < body.txt"}}'
check "node-preload-flag-then-sending-script" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"x","command":"node -r '"$T"'/clean.mjs '"$T"'/notify.mjs"}}'
check "structural-suite-runs-unquoted" allow '{"tool_name":"Bash","cwd":"/Users/orenmagid","tool_input":{"description":"run suite","command":"bash ~/.claude/hooks/tests/email-send-gate.structural.test.sh"}}'
check "judge-source-run-directly" allow '{"tool_name":"Bash","cwd":"/Users/orenmagid","tool_input":{"description":"probe","command":"EMAIL_GATE_DEBUG=1 node ~/.claude/hooks/email-send-gate.mjs < /tmp/probe.json"}}'
check "heredoc-draft-with-send-in-comment" allow '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"draft","command":"osascript '"$T"'/draft-with-comment.applescript"}}'
check "read-only-query-mentioning-send-in-string" allow '{"tool_name":"Bash","tool_input":{"description":"search","command":"osascript -e '"'"'tell application \"Mail\" to get subject of messages of inbox whose subject contains \"send\"'"'"'"}}'

# --- the quote-blanking holes, closed -------------------------------------------
check "bash-c-wrapping-a-cli-send" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"bash -c '"'"'echo hi | sendmail x@y.com'"'"'"}}'
check "sh-c-wrapping-a-cli-send" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"sh -c \"echo hi | mail -s hi x@y.com\""}}'
check "curl-quoted-smtp-url" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"curl -s --url '"'"'smtp://smtp.gmail.com:587'"'"' --mail-from a@b.com --mail-rcpt c@d.com -T msg.txt"}}'
check "curl-quoted-smtp-url+desc" ask '{"tool_name":"Bash","tool_input":{"description":"Send email from a@b.com to c@d.com, subject \"hi\"","command":"curl -s --url '"'"'smtp://smtp.gmail.com:587'"'"' --mail-from a@b.com --mail-rcpt c@d.com -T msg.txt"}}'
check "mailer-by-absolute-path" deny '{"tool_name":"Bash","tool_input":{"description":"x","command":"/usr/sbin/sendmail -t < msg.txt"}}'

# --- heuristics still apply when the gate cannot see everything ------------------
check "name-token-plus-uninspected-package" deny '{"tool_name":"Bash","cwd":"'"$T"'","tool_input":{"description":"report","command":"node '"$T"'/send-report.mjs"}}'
check "echo-of-a-smtp-url-is-not-a-send" allow '{"tool_name":"Bash","tool_input":{"description":"print","command":"echo \"curl smtp://host is how you would do it\""}}'

# --- the gate's own files: the installed copy AND the claude-cabinet template are exempt by location;
#     the same basename anywhere else is judged like any script (a real send there is still caught) ---
REPO_T=$(mktemp -d /tmp/gate-repo.XXXXXX); mkdir -p "$REPO_T/templates/hooks/tests" "$REPO_T/elsewhere"
cp "$T/notify.mjs" "$REPO_T/templates/hooks/email-send-gate.mjs"
cp "$T/notify.mjs" "$REPO_T/elsewhere/email-send-gate.mjs"
cp "$T/run.sh" "$REPO_T/templates/hooks/tests/email-send-gate.structural.test.sh"
check "template-copy-of-the-judge-is-the-gates-own-file" allow '{"tool_name":"Bash","cwd":"'"$REPO_T"'","tool_input":{"description":"syntax check","command":"node --check '"$REPO_T"'/templates/hooks/email-send-gate.mjs"}}'
check "template-suite-is-the-gates-own-file" allow '{"tool_name":"Bash","cwd":"'"$REPO_T"'","tool_input":{"description":"run suite","command":"bash '"$REPO_T"'/templates/hooks/tests/email-send-gate.structural.test.sh"}}'
check "gate-named-file-elsewhere-is-judged" deny '{"tool_name":"Bash","cwd":"'"$REPO_T"'","tool_input":{"description":"notify","command":"node '"$REPO_T"'/elsewhere/email-send-gate.mjs"}}'
rm -rf "$REPO_T"

# The shim must refuse rather than wave through when its judge is missing.
SHIM_T=$(mktemp -d /tmp/gate-shim.XXXXXX); cp "$H" "$SHIM_T/email-send-gate.sh"
got=$(printf '%s' '{"tool_name":"Bash","tool_input":{"description":"x","command":"ls"}}' | bash "$SHIM_T/email-send-gate.sh")
case "$got" in *'"permissionDecision":"deny"'*'misconfigured'*) pass=$((pass+1)); echo "ok    shim-without-judge-fails-closed -> deny";; *) fail=$((fail+1)); echo "FAIL  shim-without-judge-fails-closed -> $got";; esac
rm -rf "$SHIM_T"

echo "passed=$pass failed=$fail"
[ -n "${_GATE_LOG_TMP:-}" ] && rm -f "$EMAIL_GATE_LOG"
[ "$fail" -eq 0 ]
