From owner-freebsd-questions@FreeBSD.ORG Thu Oct 28 16:06:44 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E8951065672 for ; Thu, 28 Oct 2010 16:06:44 +0000 (UTC) (envelope-from perrin@apotheon.com) Received: from cpoproxy1-pub.bluehost.com (cpoproxy1-pub.bluehost.com [69.89.21.11]) by mx1.freebsd.org (Postfix) with SMTP id 46DF28FC08 for ; Thu, 28 Oct 2010 16:06:43 +0000 (UTC) Received: (qmail 1683 invoked by uid 0); 28 Oct 2010 16:06:43 -0000 Received: from unknown (HELO box543.bluehost.com) (74.220.219.143) by cpoproxy1.bluehost.com with SMTP; 28 Oct 2010 16:06:43 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=apotheon.com; h=Date:From:To:Subject:Message-ID:Mail-Followup-To:References:Mime-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-Identified-User; b=Wqy5mxzFSKTK3k8rW9FmNBIoG9dkgwQ2Q4NgeH99VePbRJBZJ3a1HKwSb3H1HiAH0Vtv7Lb1zb9A3YaPStTEKa8LLv5hbSin1ttn/28Mj6zRUt1Dhczi8RQIvGLGHJ/p; Received: from c-24-8-180-234.hsd1.co.comcast.net ([24.8.180.234] helo=kukaburra.hydra) by box543.bluehost.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1PBUzx-0003xh-VO for freebsd-questions@freebsd.org; Thu, 28 Oct 2010 10:06:43 -0600 Received: by kukaburra.hydra (sSMTP sendmail emulation); Thu, 28 Oct 2010 10:01:10 -0600 Date: Thu, 28 Oct 2010 10:01:10 -0600 From: Chad Perrin To: FreeBSD Questions Message-ID: <20101028160110.GA71713@guilt.hydra> Mail-Followup-To: FreeBSD Questions References: <20101027212841.GA67716@guilt.hydra> <20101028151148.GB73337@libertas.local.camdensoftware.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="AhhlLboLdkugWU4S" Content-Disposition: inline In-Reply-To: <20101028151148.GB73337@libertas.local.camdensoftware.com> User-Agent: Mutt/1.4.2.3i X-Identified-User: {2737:box543.bluehost.com:apotheon:apotheon.org} {sentby:smtp auth 24.8.180.234 authed with ren@apotheon.org} Subject: Re: [OT] writing filters in sh X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Oct 2010 16:06:44 -0000 --AhhlLboLdkugWU4S Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 28, 2010 at 08:11:48AM -0700, Chip Camden wrote: >=20 > Here's a way to do what you're wanting to do. Unfortunately, it isn't a > generalized, single construct: >=20 > #!/bin/sh > if [ $# -ge 1 ];then > exec cat $@ | $0 > exit > fi >=20 > while read data; do > echo $data > done >=20 > My lame attempts to generalize the first paragraph into an alias, > function, or shell script have met with disappointment. I was hoping for a generalized, simple idiom for this, rather than needing to implement it myself, for demonstration purposes (and for easy reuse later, of course). Your solution does not exactly fit my preferences for simplicity, but I might include it in an article I'm writing anyway. It's simple and readable enough that it should not clutter up the article much. I tested it for some simple use cases, and it works well. Thanks for saving me a little trouble. --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --AhhlLboLdkugWU4S Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkzJnkYACgkQ9mn/Pj01uKWoTwCdG7yHo0w5ocwBe0OEqxVMQf/b ScoAoLrRqWUQlmg8SXBrns5rlflEkOHE =MFcz -----END PGP SIGNATURE----- --AhhlLboLdkugWU4S--