send-file.sh 过期:缺少必填 flag 且会将项目全部文件打入 ZIP#52
Conversation
…late HTML in temp dir Fixes two issues with send-file.sh: 1. Pass --tag, --category, --project to sth send (now required by CLI) 2. Copy HTML to a temp directory before sending to avoid packaging the entire project directory into the upload ZIP
…rt --flag=VALUE syntax, directory check
…ards for --flag= syntax - Replace exec with direct invocation so trap cleanup EXIT fires and temp directory is properly removed after upload - Add empty-value validation for --tag=, --category=, --project= forms - Simplify redundant directory existence check before file check
Review feedback: --server=* branch was missing the same empty-value validation that --tag=*, --category=*, and --project=* already had.
Replace cd+pwd+basename with realpath(1) for resolving the target file path, as suggested by review. This handles symlinks correctly and is more semantically clear.
After the argument parsing loop, $1 is empty because all positional parameters have been consumed. Save the original filename before calling realpath so the error message is actually helpful.
…m realpath, signal traps - Unify --flag= empty value error messages to match --flag format - Add SIGINT/SIGTERM traps alongside EXIT for tmpdir cleanup - Add macOS-compatible realpath fallback using dirname/pwd - Document sibling resource workflow in SKILL.md
…realpath fallback
Address review feedback: initialize tmpdir="" before mktemp and use
${tmpdir:-} in cleanup to be robust under set -u.
…pace, secure tmpdir
…nsion check Move trim operation before required parameter checks so whitespace-only values (e.g. --tag ' ') are caught. Add .html/.htm extension validation to prevent accidental non-HTML uploads.
…sensitive extension check
…path fallback
- Replace ${filename,,} with tr for macOS Bash 3.2 compatibility
- Move trim() function definition to top with other helpers
- Pre-extract basename before cd in fallback path resolution
…implify path fallback - Extract require_value() helper to reduce duplicated option validation - Accept values starting with '-' (remove false-positive rejection) - Make cd+pwd path fallback error handling more explicit
… sth send example to docs
…s, clarify symlink fallback
…-f compat - Probe readlink -f with a known path (/) before using it, so macOS BSD readlink falls through to the cd+pwd fallback instead of emitting a misleading 'file not found' error. - Replace allowed_exts loop with a case statement for extension matching, improving readability.
|
无遗漏 PR 完整实现了 Issue #50 中提出的两个需求:
附加实现(Issue 未明确要求但 PR body 承诺的)也全部到位:路径解析三种 fallback、扩展名校验、 |
|
有条件合并 审查摘要整体代码质量较高,逻辑清晰,错误处理完整,安全性处理得当。但有以下几个需要注意的问题。 阻塞项
建议项
|
- usage() now accepts exit code parameter; --help/-h exit 0, errors exit 1 - Replace echo with printf for filename to avoid dash-prefixed filename issues - Add directory validation for bootstrap-repo.sh output
|
发现遗漏 分析经逐条比对 Issue #50 的需求与 PR 实现代码:
Issue #50 的两项核心需求(必填参数透传、临时目录隔离)及 PR body 中声明的全部附加特性均已实现,代码中没有遗漏任何 spec 要求的特性。无遗漏。 |
|
有条件合并 审查摘要整体代码质量高:参数解析完整、错误处理周到、临时目录隔离方案正确(EXIT trap + chmod 700)、路径解析三种 fallback 稳健。但有一个阻塞问题。 阻塞项
建议项
非阻塞说明:先前 reviewer 提到的" |
Add a --) case before the catch-all -* so that -- is properly recognized as the POSIX end-of-options marker, allowing filenames starting with -.
|
无遗漏 Issue #50 的两项核心需求(
未发现 spec 提及但未实现的任何特性。 |
|
可合并 代码质量高:必填参数解析和空值校验完整,临时目录隔离方案正确( 阻塞项:无 建议项:
|






Problem
scripts/send-file.shhad two breaking issues:sth sendrequires--tag,--category, and--project, butsend-file.shnever passed them, causing every invocation to fail with--tag is required.sth senduses the HTML file's parent directory as the archive root. When the HTML lives inside a large project repo, every file in the repo gets packed into the ZIP, triggering the server-sideuploaded archive contains too many fileslimit.Approach
Rewrite
send-file.shto accept and forward the required flags, and isolate the HTML file before uploading:--tag,--category,--project, and--server(with--flag=VALUEsyntax). Empty/whitespace values are rejected with clear errors. A--helpflag prints usage.cp'd into amktemp -dwithchmod 700, so only that single file is packaged into the upload ZIP. AnEXITtrap cleans up the temp dir aftersth sendcompletes (exec replaced with direct call so the trap fires).realpathwithreadlink -fandcd+pwdfallbacks for cross-platform compatibility. Validates the file exists and has an.html/.htmextension before proceeding.SKILL.mdnow shows the required flags in the usage example and documents the temp-dir isolation behavior, with a note to usesth senddirectly when sibling resources are needed.Tests
send-file.shrejects invocations missing--tag/--category/--projectwith specific error messages.--helpand-hprint usage and exit.realpath,readlink -f, and thecd+pwdfallback.--flag=VALUEand--flag VALUEsyntax both work; empty values (including--flag=with trailing whitespace) are caught.Closes #50