new* helpers can read from stdin

Did you know that new* helpers can read from stdin? Well, now you know! So instead of writing to a temporary file you can install your inline text straight to the destination:

src_install() {
  # old code
  cat <<-EOF >"${T}"/mywrapper || die
    #!/bin/sh
    exec do-something --with-some-argument
  EOF
  dobin "${T}"/mywrapper

  # replacement
  newbin - mywrapper <<-EOF
    #!/bin/sh
    exec do-something --with-some-argument
  EOF
}

3 thoughts on “new* helpers can read from stdin”

  1. Does that include `newmenu` from the desktop eclass for example? Or is it just limited to the default set of helpers?

    1. I haven’t tested it but I don’t see why not. As long as they are implemented on top of newins without too much trickery inside, it should work just fine.

Leave a Reply

Your email address will not be published.