Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1O1OkU-0007kq-6U for mharc-grub-devel@gnu.org; Mon, 12 Apr 2010 14:52:42 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O1OkT-0007kl-0d for grub-devel@gnu.org; Mon, 12 Apr 2010 14:52:41 -0400 Received: from [140.186.70.92] (port=60981 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1OkR-0007kc-LP for grub-devel@gnu.org; Mon, 12 Apr 2010 14:52:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O1OkQ-0005bG-2A for grub-devel@gnu.org; Mon, 12 Apr 2010 14:52:39 -0400 Received: from smarthost03.mail.zen.net.uk ([212.23.3.142]:52455) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1OkP-0005b3-Tq for grub-devel@gnu.org; Mon, 12 Apr 2010 14:52:38 -0400 Received: from [82.69.40.219] (helo=riva.pelham.vpn.ucam.org) by smarthost03.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1O1OkN-0004W2-7c; Mon, 12 Apr 2010 18:52:35 +0000 Received: from cjwatson by riva.pelham.vpn.ucam.org with local (Exim 3.36 #1 (Debian)) id 1O1OkD-0002aT-00; Mon, 12 Apr 2010 19:52:25 +0100 Date: Mon, 12 Apr 2010 19:52:24 +0100 From: Colin Watson To: The development of GNU GRUB Message-ID: <20100412185224.GL11833@riva.ucam.org> References: <20100410211015.GA26131@pina.cat> <20100412000906.GG11833@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Originating-Smarthost03-IP: [82.69.40.219] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: marcos@softastur.org, malditoastur@gmail.com Subject: Re: escape strings in grub.cfg X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2010 18:52:41 -0000 On Mon, Apr 12, 2010 at 12:23:01PM -0500, richardvoigt@gmail.com wrote: > On Sun, Apr 11, 2010 at 7:09 PM, Colin Watson wrote: > > On Sat, Apr 10, 2010 at 10:10:15PM +0100, Carles Pina i Estany wrote: > >> +gettext_escape_double_quotes () > >> +{ > >> +  echo -n $(gettext $@) | sed 's/\"/\\\"/' > >> +} > > > > This is underquoted, and in any case the 'echo -n' is redundant since > > gettext itself already writes to standard output and $() substitution > > strips trailing newlines.  $@ requires special treatment, and that sed > > s/// command needs /g.  With my suggestion, I'd recommend: > > > >  gettext_quoted () { > >    gettext "$@" | sed "s/'/'\\\\''/g" > >  } > > I haven't tried it myself, but you just said the newline is stripped > by $() and then took out the $(), seems like the newline would be > present again. In context, gettext_quoted would always be called from inside $(), so this isn't a problem. (In general I find that it's best to write shell functions such that they emit trailing newlines on their output, and let the caller strip it if necessary; this usually comes out quite naturally. Of course there are exceptions.) -- Colin Watson [cjwatson@ubuntu.com]