Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Dec 2017 08:29:30 -0800
From:      Matt Joras <matt.joras@gmail.com>
To:        Devin Teske <devin@shxd.cx>
Cc:        Hans Petter Selasky <hps@selasky.org>, rgrimes@freebsd.org, cem@freebsd.org, Eitan Adler <eadler@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r326554 - in head: . usr.bin/sponge usr.bin/sponge/tests usr.bin/tee
Message-ID:  <CADdTf%2Bhzcn2S6DjKMY5JBSjjYioQ5qSkVPPYG=wH4YrHBRmRDg@mail.gmail.com>
In-Reply-To: <16BDAEF5-87B3-482F-B5AB-372E128D0514@shxd.cx>
References:  <201712051258.vB5CwjQN051356@pdx.rh.CN85.dnsmgr.net> <22918eec-4c98-01e4-4c63-e145fbc6eab9@selasky.org> <AE022237-A2D5-49E1-A6DA-DD65A460B266@shxd.cx> <CADdTf%2Bh=Tqb635r7e8U8HdZQtwSdNtzcoC4hXuhRk7ir=TXviw@mail.gmail.com> <CADdTf%2BiWp149DifcSA7K-6DzzOzyHpbsGDC2FNvnFGdoe0Yrfg@mail.gmail.com> <CADdTf%2BhLaLUb=XF9jAqPOx7TgFXrWyf3PJywP-KsaDrvu3xs4w@mail.gmail.com> <16BDAEF5-87B3-482F-B5AB-372E128D0514@shxd.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Dec 5, 2017 at 8:06 AM, Devin Teske <devin@shxd.cx> wrote:
>
>
> The problems I have are:
>
> 1. Should be in ports
>
> Not pre-installed on Linux, why should we have it in base?
"Pre-installed on Linux" is meaningless. The closest analog to our
base is arguably GNU coreutils. It is indeed not part of GNU coreutils
but then again there are several things in our base that are not in
coreutils, and vice versa. Why should we have anything in base? If
people find it useful and it doens't have a high cost of
maintainership then why not have it?

> If in base, people will target it thinking it solves a need that can't
> otherwise be solved and thus end up creating a script that is less portable
> because it is encumbered with dependencies specific to our base.
It's not even a homegrown idea though... As we've already covered this
is a tool that exists in the broader OSS ecosystem. As long as it is
compatible with the more common implementation I don't see the issue.
Anything one writes using it is just "encumbered" with a dependency on
sponge.

> 2. Teaches bad practice
>
> sed ... somefile | sponge somefile
>
> Ignores if there is a sed error and indiscriminately zeroes somefile.

Calling this unequivocally bad practice is silly. There are plenty
uses of sponge that aren't bad practice. I have a git commit hook that
utilizes sponge to do the same "auto-culling" that our svn patches do.
I like the sponge version better than creating temporary files myself:

sed '/^$/d' $(git config commit.message) | awk 'NR==FNR{a[$0];next}
!($0 in a)' /dev/fd/0 "$1" | sponge "$1"

> 3. Solution in search of a problem
Again, stating this unequivocally is silly. I discovered sponge years
ago when I was searching how best to handle something where I wanted
to write output back to the same file in a shell pipeline. I was
literally someone with a problem in search of a solution, and that
solution was and still is sponge. Since then I have seen it
recommended numerous times in passing.

Matt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CADdTf%2Bhzcn2S6DjKMY5JBSjjYioQ5qSkVPPYG=wH4YrHBRmRDg>