Re: git: 566cc005812b - main - safe_set treat ':' and '#' differently
- Reply: Dag-Erling_Smørgrav : "Re: git: 566cc005812b - main - safe_set treat ':' and '#' differently"
- Reply: Simon J. Gerraty: "Re: git: 566cc005812b - main - safe_set treat ':' and '#' differently"
- In reply to: Simon J. Gerraty : "git: 566cc005812b - main - safe_set treat ':' and '#' differently"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 27 Apr 2026 10:47:04 UTC
Simon J. Gerraty <sjg@FreeBSD.org> writes:
> The branch main has been updated by sjg:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=566cc005812b72a4ba236764651dd8e82c94a166
>
> commit 566cc005812b72a4ba236764651dd8e82c94a166
> Author: Simon J. Gerraty <sjg@FreeBSD.org>
> AuthorDate: 2026-04-22 16:37:35 +0000
> Commit: Simon J. Gerraty <sjg@FreeBSD.org>
> CommitDate: 2026-04-22 16:37:35 +0000
>
> safe_set treat ':' and '#' differently
>
> Treat '#' as a comment anywhere,
> but ':' only at start of line.
I can't quite figure out what your goal is with this, but it doesn't
seem right: `:` is not at all a comment, it is just a built-in alias for
the `true` command. Among other things, this means that (assuming a
clean environment) these lines do absolutely nothing:
# ${foo:=bar} >baz ; echo $foo
#${foo:=bar} >baz ; echo $foo
while this line:
: ${foo:=bar} >baz ; echo $foo
sets the variable `foo` to `bar`, creates or truncates the file `baz`,
and finally prints `bar\n` to stdout; and this line:
:${foo:=bar} >baz ; echo $foo
creates or truncate the file `baz`, emits an error to stderr because the
command `:bar` does not exist, and finally prints `bar\n` to stdout. It
also means that this line:
foo=bar # hello
sets `foo` to `bar`, but this one:
foo=bar : hello
does not (or, more accurately, it does, but only for the duration of the
`:` command).
(except in our sh, but that's a bug)
DES
--
Dag-Erling Smørgrav - des@FreeBSD.org