From owner-freebsd-questions@FreeBSD.ORG Sat Dec 31 05:56:41 2011 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 CB1C7106564A for ; Sat, 31 Dec 2011 05:56:41 +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 99BCA8FC16 for ; Sat, 31 Dec 2011 05:56:41 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email2.allantgroup.com (8.14.4/8.14.4) with ESMTP id pBV5udj8087618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 30 Dec 2011 23:56:39 -0600 (CST) (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 pBV5ude6070030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 30 Dec 2011 23:56:39 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.5/8.14.5/Submit) id pBV5uckV070029; Fri, 30 Dec 2011 23:56:39 -0600 (CST) (envelope-from dan) Date: Fri, 30 Dec 2011 23:56:38 -0600 From: Dan Nelson To: Erik Trulsson Message-ID: <20111231055638.GB24192@dan.emsphone.com> References: <4EFE645B.8010906@gmail.com> <4EFE77D1.3090402@gmail.com> <20111231015640.GA38111@owl.midgard.homeip.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111231015640.GA38111@owl.midgard.homeip.net> X-OS: FreeBSD 8.2-STABLE 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 [199.67.51.78]); Fri, 30 Dec 2011 23:56:39 -0600 (CST) X-Scanned-By: MIMEDefang 2.68 on 199.67.51.78 Cc: nm.knife@gmail.com, FreeBSD Questions , Edward Martinez Subject: Re: why newline scape sequence does not work in Freebsd's bash 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: Sat, 31 Dec 2011 05:56:42 -0000 In the last episode (Dec 31), Erik Trulsson said: > On Fri, Dec 30, 2011 at 06:47:45PM -0800, Edward Martinez wrote: > > On 12/30/11 17:06, ??????? ???????? wrote: > > > I used ' singe quotes, so double quotes is: > > > > > > $ FRUIT_BASKET="apples oranges pears" > > > $ echo -e "My fruit basket contains: \n $FRUIT_BASKET" > > > My fruit basket contains: > > > apples oranges pears > > > > Thanks for the help, it worked. I find it interesting that FreeBSD's > > echo man page does not mention the -e option is needed to enable > > backslash escapes. I remembered why it worked on linux is because i > > created an echo alias with the -e option. So i will do the same for > > FreeBSD. > > The echo(1) manpage on FreeBSD doesn't say anything about '-e' because > that version of echo doesn't have such an option. The echo you were > actually using is the one builtin into bash and is described in the > bash(1) manpage (including mention of the -e option.) If you want a command guaranteed to process backslash-escape sequences, use the printf command, not echo. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html It is not possible to use echo portably across all POSIX systems unless both -n (as the first argument) and escape sequences are omitted. The printf utility can be used portably to emulate any of the traditional behaviors of the echo utility as follows (assuming that IFS has its standard value or is unset). New applications are encouraged to use printf instead of echo. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html The %b conversion specification is not part of the ISO C standard; it has been added here as a portable way to process -escapes expanded in string operands as provided by the echo utility. See also the APPLICATION USAGE section of echo for ways to use printf as a replacement for all of the traditional versions of the echo utility. -- Dan Nelson dnelson@allantgroup.com