Live data from Hacker News

Moreutils – Unix tools that nobody thought to write (2012)

joeyh.name

171–180 of 225 posts

Re: Moreutils – Unix tools that nobody thought to write (2012)

#171
post #124

I seriously hate this package and the manner of combining different utils with different names in a same package in general. The reason being, "sponge" is an actually useful tool and for me it's pretty much the only useful tool in the package. So I need to install whole moreutils package on ubuntu to have "sponge" and I have to clog my bin namespace with all this trash. It would be mildly annoying from the perfection…

In version 7, ImageMagick has switched to just "magick" instead of "convert", "mogrify" etc., and for compatibility with version 6 it still supports subcommands like "magick convert" etc., but at least the namespace cluttering is gone.

https://imagemagick.org/script/command-line-tools.php

Edit: I wasn't quite right, the commands still exist, but they are symlinks to "magick" and can be called using the subcommand mentioned above; you still have to delete the symlinks to clean up the namespace.

https://imagemagick.org/script/porting.php#cli

Re: Moreutils – Unix tools that nobody thought to write (2012)

#172
post #124

I seriously hate this package and the manner of combining different utils with different names in a same package in general. The reason being, "sponge" is an actually useful tool and for me it's pretty much the only useful tool in the package. So I need to install whole moreutils package on ubuntu to have "sponge" and I have to clog my bin namespace with all this trash. It would be mildly annoying from the perfection…

you raise a great point. why not install the package, then delete the /usr/bin files you don't need? would it solve the problem if the author namespaced the commands with a hyphenated prefix? curious about these considerations, which it seems like you've spent time thinking about. what do you see as the "best practices" regarding a set of utilities that are maintained and published together?

I remember building the gnu core tools on sun os and solaris boxes. I had a license to the compiler from sun, then I would get GNU compiler going, then I'd get the whole GNUniverse going.

The GNU build/install process let you set a prefix, so it was customary to specify `g` get prefixed, so `gmore` and `gcd` etc. if you were afraid of breaking old user scripts that used the sun versions.

The build for this looks pretty simple. I cloned the source, ran "make". I got some XML errors about docbook, but it did create a `sponge`

  otool -L sponge
  sponge:
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
looks like one could copy it to `~/bin/`

Re: Moreutils – Unix tools that nobody thought to write (2012)

#173
post #15

Nice collection of quite useful tools. Some of these can be easily replicated by using a more modern shell (bash, zsh) like mispipe, others are just shortcuts (e.g. ifne, chronic). But what immediately stood out to me is `vidir`. I really like the idea of editing file names with an editor. Using loops and regex in a shell for mass renaming can be a mess. It should be way easier with `vim`. This tool made me install m…

Emacs has dired for that reason. Imagine ls that you can edit.

Re: Moreutils – Unix tools that nobody thought to write (2012)

#174
post #124

I seriously hate this package and the manner of combining different utils with different names in a same package in general. The reason being, "sponge" is an actually useful tool and for me it's pretty much the only useful tool in the package. So I need to install whole moreutils package on ubuntu to have "sponge" and I have to clog my bin namespace with all this trash. It would be mildly annoying from the perfection…

Don't most shells implement something like ">"? How is sponge an improvement on this?

Re: Moreutils – Unix tools that nobody thought to write (2012)

#175

I wish there was a short and simple command for “list all files of a directory and no subdirectories“. ls doesn’t seem to have a switch for that kind of functionality. It’s discussed on stack-overflow. [0] Someone even wrote a nodejs tool for this functionality [1], but I would rather have something written in a compiled language. [0]: https://stackoverflow.com/questions/10574794/how-to-list-onl... [1]: https://githu…

Try submitting a pr to exa. Probably the fastest way to get it solved properly.

Re: Moreutils – Unix tools that nobody thought to write (2012)

#176
post #123

Earlier quoted context omitted.

sponge buffers the whole input before writing the output. Its utility would be in reading from a file, working on it with other tools, and writing the result back to the original file, all in one line.

I know I wanted to do this, but I am very happy such a utility doesn't exist. Unix utilities, usually work in a pipeline fashion, read line -> process -> write to output. This allows them to allocate a limited amount of memory. If you read all input in memory, you are asking for trouble: 'cat /dev/zero | sponge a'.

I routinely operate on machines with gigabytes of memory, but rarely write pipelines which output gigabytes of data, so this has never been a concern for me. But even then, there’s still swap space which is effectively like using a temp file but lazier.

By the way, I think you’d be in even more trouble if you wrote:

    cat /dev/zero > a

Re: Moreutils – Unix tools that nobody thought to write (2012)

#177
post #124

I seriously hate this package and the manner of combining different utils with different names in a same package in general. The reason being, "sponge" is an actually useful tool and for me it's pretty much the only useful tool in the package. So I need to install whole moreutils package on ubuntu to have "sponge" and I have to clog my bin namespace with all this trash. It would be mildly annoying from the perfection…

you raise a great point. why not install the package, then delete the /usr/bin files you don't need? would it solve the problem if the author namespaced the commands with a hyphenated prefix? curious about these considerations, which it seems like you've spent time thinking about. what do you see as the "best practices" regarding a set of utilities that are maintained and published together?

Your package manager will still see that the two packages want to own the same file and give you a conflict error unless you force install which it's very messy. Namespacing the commands would solve this.

But in general it is bad practice to package a bunch of unrelated tools together. You should be able to install them separately to only have what you need. Youd want different packages for each command or sets of related commands with common dependencies. And then have a meta package that includes all of your packages for people who want to install it all in one go.

Re: Moreutils – Unix tools that nobody thought to write (2012)

#178
post #174
post #124

I seriously hate this package and the manner of combining different utils with different names in a same package in general. The reason being, "sponge" is an actually useful tool and for me it's pretty much the only useful tool in the package. So I need to install whole moreutils package on ubuntu to have "sponge" and I have to clog my bin namespace with all this trash. It would be mildly annoying from the perfection…

Don't most shells implement something like ">"? How is sponge an improvement on this?

In the provided example

  % sed "s/root/toor/" /etc/passwd | grep -v joey | sponge /etc/passwd
It looks like this allows an in place modification to the same doc. If you used

  % sed "s/root/toor/" /etc/passwd | grep -v joey > /etc/passwd
Bash will process the redirection first, then execute the commands in the pipe. So, it will have cleared out /etc/passwd with the non-appending redirection ">" before sed operates on it. You'd end up with a blank /etc/passwd file. (ymmv, I don't know how other shells would handle this)

Sponge, it seems, would cause the pipe to allow the preceding commands to complete before it outputs.

Re: Moreutils – Unix tools that nobody thought to write (2012)

#179
post #174
post #124

I seriously hate this package and the manner of combining different utils with different names in a same package in general. The reason being, "sponge" is an actually useful tool and for me it's pretty much the only useful tool in the package. So I need to install whole moreutils package on ubuntu to have "sponge" and I have to clog my bin namespace with all this trash. It would be mildly annoying from the perfection…

Don't most shells implement something like ">"? How is sponge an improvement on this?

you can sudo sponge, and not run the entire command with elevated privileges.

(i'd welcome a method of doing that in zsh.)

Re: Moreutils – Unix tools that nobody thought to write (2012)

#180
post #124

I seriously hate this package and the manner of combining different utils with different names in a same package in general. The reason being, "sponge" is an actually useful tool and for me it's pretty much the only useful tool in the package. So I need to install whole moreutils package on ubuntu to have "sponge" and I have to clog my bin namespace with all this trash. It would be mildly annoying from the perfection…

Since Debian Stretch / Ubuntu 17.04 they do the right thing.

If you install parallel & moreutils you get the GNU parallel as /usr/bin/parallel and moreutil's parallel as /usr/bin/parallel.moreutils. If you only install moreutils, it provides /usr/bin/parallel.

You can use the debian alternatives system to flip the order.

https://superuser.com/a/1253492/78988

Post reply on HN