Skip to content

Commit 4d9b19b

Browse files
redsun82Copilot
andcommitted
Just: draw the separator out of the # that starts it
A `#` followed by dashes reads as two things, a comment marker and then a rule. Repeating the `#` makes it one, and the line is a shell comment for the same reason it is a rule. Width is unchanged at 57 columns with no terminal, so logs keep their shape; only the glyph differs. The `#` stays in `cmd_sep` rather than moving into the rule, so a preset `JUST_CMD_RULE` cannot produce a line that the shell would try to run. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent ca68b9b commit 4d9b19b

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

misc/just/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,6 @@ counting measurements. Presetting `JUST_CMD_RULE` skips all of them, and is also
164164
fix the width in CI or in a recording.
165165

166166
With no terminal to ask — a pipe, a log, a shell without `stty` — it falls back to a
167-
fixed 56 characters, so anything not attached to a terminal looks as it always did. That
168-
is one branch rather than a platform test: `just` runs `sh` everywhere, so Windows takes
167+
fixed 57 columns, so logs and CI output are the same width every time. That is one
168+
branch rather than a platform test: `just` runs `sh` everywhere, so Windows takes
169169
whichever arm fits rather than a path of its own.

misc/just/defs.just

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ error := f'{{ style("error") }}error{{ NORMAL }}: '
2020
# the terminal from stdin, so it answers when stdout is piped. The arithmetic is in the
2121
# shell because just has no integers.
2222
#
23-
# With no terminal the value is non-numeric and this falls back to the 56 dashes used
24-
# before. That is a branch, not a platform test: just runs `sh` everywhere.
23+
# With no terminal the value is non-numeric and this falls back to a fixed 57 columns.
24+
# That is a branch, not a platform test: just runs `sh` everywhere.
25+
#
26+
# The leading `#` is in `cmd_sep`, not in the rule, so the line stays a comment whatever
27+
# `JUST_CMD_RULE` is set to.
2528
#
2629
# Exported and preferred over measuring: `shell()` runs on every parse, so a forwarded
2730
# verb would otherwise re-measure in every child it spawns, and `if` is lazy in its
@@ -30,7 +33,7 @@ error := f'{{ style("error") }}error{{ NORMAL }}: '
3033
_rule := if env('JUST_CMD_RULE', '') != '' { env('JUST_CMD_RULE', '') } else { shell('''
3134
w=$(stty size 2>/dev/null | cut -d" " -f2)
3235
case "$w" in '' | *[!0-9]*) w=57 ;; esac
33-
printf "%*s" $((w - 1)) "" | tr " " -
36+
printf "%*s" $((w - 1)) "" | tr " " '#'
3437
''') }
3538

3639
export JUST_CMD_RULE := _rule

0 commit comments

Comments
 (0)