Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Apr 2026 12:47:04 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        Simon J. Gerraty <sjg@FreeBSD.org>
Cc:        src-committers@FreeBSD.org,  dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   Re: git: 566cc005812b - main - safe_set treat ':' and '#' differently
Message-ID:  <86jyts1xzr.fsf@ltc.des.dev>
In-Reply-To: <69e8f964.39869.24418b55@gitrepo.freebsd.org> (Simon J. Gerraty's message of "Wed, 22 Apr 2026 16:37:56 %2B0000")
References:  <69e8f964.39869.24418b55@gitrepo.freebsd.org>

index | next in thread | previous in thread | raw e-mail

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


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86jyts1xzr.fsf>