From owner-freebsd-questions@FreeBSD.ORG Tue Jun 5 17:06:58 2012 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 AAEA91065677 for ; Tue, 5 Jun 2012 17:06:58 +0000 (UTC) (envelope-from tundra@tundraware.com) Received: from ozzie.tundraware.com (ozzie.tundraware.com [75.145.138.73]) by mx1.freebsd.org (Postfix) with ESMTP id 67A1F8FC0C for ; Tue, 5 Jun 2012 17:06:58 +0000 (UTC) Received: from [192.168.2.109] ([12.106.254.160]) (authenticated bits=0) by ozzie.tundraware.com (8.14.5/8.14.5) with ESMTP id q55H6mSe051168 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Tue, 5 Jun 2012 12:06:49 -0500 (CDT) (envelope-from tundra@tundraware.com) Message-ID: <4FCE3CA2.50106@tundraware.com> Date: Tue, 05 Jun 2012 12:06:42 -0500 From: Tim Daneliuk Organization: TundraWare Inc. User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: FreeBSD Mailing List References: <4FCE287D.3090501@tundraware.com> <20120605163522.GD16874@dan.emsphone.com> In-Reply-To: <20120605163522.GD16874@dan.emsphone.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (ozzie.tundraware.com [75.145.138.73]); Tue, 05 Jun 2012 12:06:50 -0500 (CDT) X-TundraWare-MailScanner-Information: Please contact the ISP for more information X-TundraWare-MailScanner-ID: q55H6mSe051168 X-TundraWare-MailScanner: Found to be clean X-TundraWare-MailScanner-From: tundra@tundraware.com X-Spam-Status: No Subject: Re: Possible /bin/sh Bug? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: tundra@tundraware.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jun 2012 17:06:58 -0000 On 06/05/2012 11:35 AM, Dan Nelson wrote: > 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: > > Ah, OK, that makes sense, thanks... -- ----------------------------------------------------------------------- Tim Daneliuk