Jens-G opened a new pull request, #3887:
URL: https://github.com/apache/thrift/pull/3887
Three smaller defects in `build/veralign.sh`, which came up while working on
THRIFT-6301.
### `jsonReplace` could not report a failure
```bash
result=$?
if [ $? -ne 0 ]; then
```
The second `$?` is the status of the assignment `result=$?`, which is always
0, so the error branch never ran. As a result:
- A malformed `package.json`, or one whose rewrite failed, was reported as
OK and kept its old version, with exit 0. A `tmp.<pid>.json` was left in the
source root.
- A `package.json` without a `version` field silently had one added.
`jsonReplace` now reads the version first. If there is none, it stops with
"version tag not found". It also checks the rewrite itself and removes the
temporary file when that fails. The error branch no longer prints `$count`,
which `jsonReplace` never set.
### The file lists were not sorted
`for file in $(echo "${!FILES[@]}" | sort)` hands `sort` a single line, so
the files were processed in the associative array's hash order. The same went
for the list of files to edit by hand. Since the script stops at the first
failure, that order also decided which files had already been rewritten by
then. With `printf '%s\n'` both lists come out sorted.
Also fixes "hilighted", "hilighting" and "striing" in comments.
### Verification
I ran the script before and after the change on exported trees, from their
root:
| Case | Before | After |
|---|---|---|
| malformed `lib/js/package.json` | OK, exit 0, temp file left | ERROR, exit
1, no temp file |
| `package.json` without `version` | OK, version added, exit 0 | ERROR, exit
1 |
| the same with `DRYRUN` | MATCHES `"null"`, exit 0 | ERROR, exit 1 |
| rewrite fails (`mv` shimmed to fail) | OK, old version kept, temp file
left, exit 0 | ERROR, exit 1, no temp file |
| file table and manual list | hash order | sorted |
Bumps from 0.25.0 on aedcb6ec4 and from 0.26.0 on d61a908ea write exactly
the same 146 lines as before. A full `DRYRUN` changes nothing. shellcheck
reports one SC2181 fewer and nothing new, and codespell is clean.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]