From owner-freebsd-questions@FreeBSD.ORG Tue Jun 5 16:38:39 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 414781065675 for ; Tue, 5 Jun 2012 16:38:39 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email2.allantgroup.com (email2.emsphone.com [199.67.51.116]) by mx1.freebsd.org (Postfix) with ESMTP id 013C68FC0A for ; Tue, 5 Jun 2012 16:38:38 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [172.17.17.101]) by email2.allantgroup.com (8.14.4/8.14.4) with ESMTP id q55GZN7U090201 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 5 Jun 2012 11:35:23 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.5/8.14.5) with ESMTP id q55GZMu2035198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 5 Jun 2012 11:35:22 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.5/8.14.5/Submit) id q55GZMPE035197; Tue, 5 Jun 2012 11:35:22 -0500 (CDT) (envelope-from dan) Date: Tue, 5 Jun 2012 11:35:22 -0500 From: Dan Nelson To: Tim Daneliuk Message-ID: <20120605163522.GD16874@dan.emsphone.com> References: <4FCE287D.3090501@tundraware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FCE287D.3090501@tundraware.com> X-OS: FreeBSD 8.3-PRERELEASE User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.97.2 at email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.6 (email2.allantgroup.com [172.17.19.78]); Tue, 05 Jun 2012 11:35:23 -0500 (CDT) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on email2.allantgroup.com X-Scanned-By: MIMEDefang 2.68 on 172.17.19.78 Cc: FreeBSD Mailing List Subject: Re: Possible /bin/sh Bug? 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: Tue, 05 Jun 2012 16:38:39 -0000 In the last episode (Jun 05), Tim Daneliuk said: > Given this script: > #!/bin/sh > > foo="" > while read line > do > foo="$foo -e" > done > echo $foo > > Say I respond 3 times, I'd expect to see: > > -e -e -e > > Instead, I get: > > -e -e > > Linux appears to do the right thing here, so this seems like it > is a bug ... or am I missing something? echo takes a -e flag, so it eats the first one. Bash does the same thing, so any Linux that uses bash as /bin/sh will also. You must be testing on a Linux that uses something else as /bin/sh. Better to use the printf command if you are worried about compatibility. echo [-e | -n] [string ...] Print a space-separated list of the arguments to the standard output and append a newline character. -n Suppress the output of the trailing newline. -e Process C-style backslash escape sequences. The echo command understands the following character escapes: -- Dan Nelson dnelson@allantgroup.com