From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 28 14:58:23 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 736961065694; Sat, 28 Aug 2010 14:58:23 +0000 (UTC) (envelope-from swell.k@gmail.com) Received: from mail-gy0-f182.google.com (mail-gy0-f182.google.com [209.85.160.182]) by mx1.freebsd.org (Postfix) with ESMTP id D4C558FC0C; Sat, 28 Aug 2010 14:58:22 +0000 (UTC) Received: by gyg4 with SMTP id 4so1751345gyg.13 for ; Sat, 28 Aug 2010 07:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=RTbvtGaTmyCnwmFyesN8p16VJBKRAIoPiJxdbwfoHWo=; b=jZI/LdLZbhgbA3OU7SV5k9T9cqAO1Auotyee2u9dDB6tayHOUObtg/RY7H9RXwOeoO nArp/s+Tjvr9GKcKstzlwW5Aoqgk3SRzZ0qEqLfyZUqbFkCbi3B6B+apUGAnMwn9cwTO d+4JrSOfNXeYrLsG+o9WQlFL3ohWz+ooTG5Mk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=v4xFR7+xGMSGBphYBlxBTdRtZM2uJnPA2ulWAE7kCjMASutJ/qPp4g2qyiDXBSe6WG EwkOzonZUIeU/TiBOZZgw2Y99rg1tJCLdDRt90vkVND93iU7SgLUgw7RzgnGwpre1rRe JS2XS+FEBXTLrnE/L8+v3WTARbaRCwogGhX00= Received: by 10.151.77.8 with SMTP id e8mr3317834ybl.224.1283007442537; Sat, 28 Aug 2010 07:57:22 -0700 (PDT) Received: from localhost (tor-exit-proxy2-readme.formlessnetworking.net [208.53.142.38]) by mx.google.com with ESMTPS id q25sm5318839ybk.6.2010.08.28.07.57.20 (version=SSLv3 cipher=RC4-MD5); Sat, 28 Aug 2010 07:57:21 -0700 (PDT) From: Anonymous To: Alexander Best References: <20100828141625.GA69240@freebsd.org> <86aao694tm.fsf@gmail.com> Date: Sat, 28 Aug 2010 18:54:27 +0400 In-Reply-To: <86aao694tm.fsf@gmail.com> (Anonymous's message of "Sat, 28 Aug 2010 18:42:29 +0400") Message-ID: <86mxs67pp8.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-hackers@freebsd.org Subject: Re: tiny patch to prevent head from closing pipes X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2010 14:58:23 -0000 Anonymous writes: > Alexander Best writes: > >> hi there, >> >> i just had subversion complain about a broken pipe while piping its output >> through awk straight to head [1]. i decided to add a switch to head which will >> tell it to never close a pipe unless the input has stopped [2]. > > You can do same with sh(1), e.g. > > $ svn log | (IFS=; while read li; do [ $((i+=1)) -le 10 ] && echo "$li"; done) Hmm, draining pipe with cat(1) would be more efficient $ svn log | (IFS=; while read li && [ $((i+=1)) -le 10 ]; do echo "$li"; done; cat >/dev/null)