From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Sipek Subject: Re: [GUILT v2 24/29] disp no longer processes backslashes. Date: Tue, 13 May 2014 17:44:19 -0400 Message-ID: <20140513214419.GJ4791@meili.valhalla.31bits.net> References: <1400013065-27919-1-git-send-email-cederp@opera.com> <1400013065-27919-25-git-send-email-cederp@opera.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: git@vger.kernel.org To: Per Cederqvist X-From: git-owner@vger.kernel.org Tue May 13 23:44:29 2014 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WkKUo-0007i1-4T for gcvg-git-2@plane.gmane.org; Tue, 13 May 2014 23:44:22 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755086AbaEMVoO (ORCPT ); Tue, 13 May 2014 17:44:14 -0400 Received: from josefsipek.net ([64.9.206.49]:1773 "EHLO josefsipek.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754745AbaEMVoN (ORCPT ); Tue, 13 May 2014 17:44:13 -0400 Received: from meili.valhalla.31bits.net (c-98-209-117-250.hsd1.mi.comcast.net [98.209.117.250]) by josefsipek.net (Postfix) with ESMTPSA id 04DC455654; Tue, 13 May 2014 17:44:11 -0400 (EDT) Content-Disposition: inline In-Reply-To: <1400013065-27919-25-git-send-email-cederp@opera.com> User-Agent: Mutt/1.5.22 (2013-10-16) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Tue, May 13, 2014 at 10:31:00PM +0200, Per Cederqvist wrote: > Only one invocation of "disp" or "_disp" actually needed backslash > processing. In quite a few instances, it was wrong to do backslash > processing, as the message contained data derived from the user. > > Created the new function "disp_e" that should be used when backslash > processing is required, and changed "disp" and "_disp" to use printf > code %s instead of "%b". Minor nit: "%s" (to match "%b") Signed-off-by: Josef 'Jeff' Sipek > Signed-off-by: Per Cederqvist > --- > guilt | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/guilt b/guilt > index 23cc2da..9947acc 100755 > --- a/guilt > +++ b/guilt > @@ -36,15 +36,24 @@ usage() > exit 1 > } > > -# echo -n is a bashism, use printf instead > +# Print arguments, but no trailing newline. > +# (echo -n is a bashism, use printf instead) > _disp() > { > - printf "%b" "$*" > + printf "%s" "$*" > } > > -# echo -e is a bashism, use printf instead > +# Print arguments. > +# (echo -E is a bashism, use printf instead) > disp() > { > + printf "%s\n" "$*" > +} > + > +# Print arguments, processing backslash sequences. > +# (echo -e is a bashism, use printf instead) > +disp_e() > +{ > printf "%b\n" "$*" > } > > @@ -117,7 +126,7 @@ else > > disp "" > disp "Example:" > - disp "\tguilt push" > + disp_e "\tguilt push" > > # now, let's exit > exit 1 > -- > 1.8.3.1 > -- Reality is merely an illusion, albeit a very persistent one. - Albert Einstein