9front - general discussion about 9front
 help / color / mirror / Atom feed
From: qwx <qwx@sciops.net>
To: 9front@9front.org
Subject: [9front] crop: allow no-ops in pipelines
Date: Mon, 12 Apr 2021 02:05:51 +0200	[thread overview]
Message-ID: <0B6D3C32FB0256660217BF6D3E67167F@wopr.sciops.net> (raw)

Hello,

Any objections to pushing this change?

Thanks,

qwx

--
crop: allow no-ops in pipelines

unlike other tools like iconv(1), a crop(1) without arguments or with
ones resulting in a no-op, like `-t 0 0', errors out.  other options
like `-i 0' do not error.  this breaks assumptions and results in
tedious intermediary steps or hacks like:

	foo | {crop -t $1 $2 >[2]/null || cat} > baz.bit

instead, just ignore the check.  subsequent code doesn't make
assumptions on it.

diff -r 936eda80a52f sys/src/cmd/crop.c
--- a/sys/src/cmd/crop.c	Sat Apr 10 15:01:09 2021 +0200
+++ b/sys/src/cmd/crop.c	Mon Apr 12 02:01:12 2021 +0200
@@ -148,9 +148,6 @@
 		usage();
 	}ARGEND
 
-	if(mode == None && cropval == 0 && eqpt(ZP, t))
-		usage();
-
 	file = "<stdin>";
 	fd = 0;
 	if(argc > 1)

             reply	other threads:[~2021-04-12  2:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12  0:05 qwx [this message]
2021-04-12  1:51 ` cinap_lenrek
2021-04-12  8:30   ` qwx

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0B6D3C32FB0256660217BF6D3E67167F@wopr.sciops.net \
    --to=qwx@sciops.net \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).