Skip to content

Commit dd441b8

Browse files
redsun82Copilot
andcommitted
Just: drop the separator check, keep the single read of the variable
The check rejected a `JUST_CMD_RULE` that was not a shell comment. That is a real failure mode, but not one worth code: setting the variable at all means being able to run commands already, so the check only defended whoever set it from themselves, and nothing sets it. The requirement is documented where the value is read, which is where someone about to set it is looking. `_given_rule` stays. Naming the value was about not spelling `env('JUST_CMD_RULE', '')` twice, which stands whether or not it is checked. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent e5ae5ea commit dd441b8

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

misc/just/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ for itself, and the count is one per `mod` reached, however deeply nested, plus
162162
the file itself. That is cheap, and modules agree anyway since they share a terminal,
163163
but it is worth knowing before counting measurements. Presetting `JUST_CMD_RULE` skips
164164
all of them, and is also how to fix the width in CI or in a recording — it is the whole
165-
separator and ends up in a shell script, so it has to be a single line starting with
166-
`#`. Anything else is rejected rather than documented against, because otherwise it
167-
runs, silently and once per place the separator appears.
165+
separator and ends up in a shell script, so every line of it has to be a comment, or it
166+
runs.
168167

169168
With no terminal to ask — a pipe, a log, a shell without `stty` — it falls back to a
170169
fixed 57 columns, so logs and CI output are the same width every time. That is one

misc/just/defs.just

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ error := f'{{ style("error") }}error{{ NORMAL }}: '
2929
# That is a branch, not a platform test: just runs `sh` everywhere.
3030
#
3131
# `JUST_CMD_RULE` is the whole separator and lands in a shell script, so a hand-set value
32-
# that is not a shell comment gets run -- silently, with a zero exit, once per place the
33-
# separator appears. Hence the check rather than a warning in prose: a rule is one line by
34-
# construction, so demanding one line starting with `#` rejects every value that would
35-
# run, without having to describe what running looks like.
32+
# has to be a shell comment, every line of it, or it runs. Left unchecked: setting it at
33+
# all means being able to run commands already, so there is nothing to defend.
3634
#
3735
# Exported and preferred over measuring: `shell()` runs on every parse, so a forwarded
3836
# verb would otherwise re-measure in every child it spawns, and `if` is lazy in its
@@ -44,7 +42,7 @@ _rule := if _given_rule == '' { shell('''
4442
w=$(stty size 2>/dev/null | cut -d" " -f2)
4543
case "$w" in '' | *[!0-9]*) w=57 ;; esac
4644
printf "%*s" $w "" | tr " " '#'
47-
''') } else if _given_rule =~ '^#[^\n]*$' { _given_rule } else { error('JUST_CMD_RULE must be a single line starting with `#`') }
45+
''') } else { _given_rule }
4846

4947
export JUST_CMD_RULE := _rule
5048

0 commit comments

Comments
 (0)