Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Dec 2017 08:06:21 -0800
From:      Devin Teske <devin@shxd.cx>
To:        Matt Joras <matt.joras@gmail.com>
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:  <16BDAEF5-87B3-482F-B5AB-372E128D0514@shxd.cx>
In-Reply-To: <CADdTf%2BhLaLUb=XF9jAqPOx7TgFXrWyf3PJywP-KsaDrvu3xs4w@mail.gmail.com>
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>

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


> On Dec 5, 2017, at 7:53 AM, Matt Joras <matt.joras@gmail.com> wrote:
> 
> 
> 
> On Dec 5, 2017 7:35 AM, "Devin Teske" <devin@shxd.cx> wrote:
> 
> > On Dec 5, 2017, at 5:00 AM, Hans Petter Selasky <hps@selasky.org> wrote:
> >
> >> On 12/05/17 13:58, Rodney W. Grimes wrote:
> >> Further more, why does freebsd need this in base?
> >
> > Hi,
> >
> > I think this is useful. It could replace the "-i " (intermediate) option for "sed" for example. It avoids creating temporary files when filtering files, right?
> >
> > --HPS
> >
> 
> Wth is wrong with:
> 
> data=$( sed -e '...' somefile ) &&
>         echo "$data" > somefile
> 
> or
> 
> set -e
> data=...
> echo "$data" > ...
> 
> or
> 
> exec 3<<EOF
> $( ... )
> EOF
> cat > ... <&3
> 
> or
> 
> (I digress)
> 
> Infinite variations, but the gist is that sponge looks to be trying to help sh(1)/similar when help is unneeded.
> 
> Why buffer data into memory via fork-exec-pipe to sponge when you can buffer to native namespace without pipe to sponge?
> 
> Am I missing something? Why do we need sponge(1)?
> --
> Devin
> 
> I do believe you are sort of missing the point. It is a utility that is explicitly useful in shell pipelines, so when you want to do things as one-liners. I like the utility and use the one from ports and my own version in various things here and there. It is a common utility installed in Linux distros and the top answer on Google for questions such as "redirect shell output to same file". I think the outrage about adding a tiny utility that's common elsewhere is a bit silly.
> 
> As for the implementation, I have my own version of sponge (hobby program written in rust so not base-worthy), and it uses explicit temporary files for larger outputs. 
> 
> Matt

The problems I have are:

1. Should be in ports

Not pre-installed on Linux, why should we have it in base?

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.

2. Teaches bad practice

sed ... somefile | sponge somefile

Ignores if there is a sed error and indiscriminately zeroes somefile.

3. Solution in search of a problem
-- 
Devin


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?16BDAEF5-87B3-482F-B5AB-372E128D0514>