From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Hansen Subject: Re: [PATCH] git-prompt.sh: shorter equal upstream branch name Date: Tue, 30 Sep 2014 23:54:32 -0400 Message-ID: <542B7AF8.6080501@bbn.com> References: <1412091370-11727-1-git-send-email-jcarsique@nuxeo.com> <542B1623.2070109@bbn.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8BIT Cc: Julien Carsique , git@vger.kernel.org, =?windows-1252?Q?SZEDER_G=E1bor?= , Felipe Contreras , Ramkumar Ramachandra , Simon Oosthoek , "Eduardo R. D'Avila" To: Junio C Hamano X-From: git-owner@vger.kernel.org Wed Oct 01 06:21:51 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 1XZBQF-0005jx-JG for gcvg-git-2@plane.gmane.org; Wed, 01 Oct 2014 06:21:51 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750859AbaJAEVi (ORCPT ); Wed, 1 Oct 2014 00:21:38 -0400 Received: from smtp.bbn.com ([128.33.1.81]:25944 "EHLO smtp.bbn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750716AbaJAEVh convert rfc822-to-8bit (ORCPT ); Wed, 1 Oct 2014 00:21:37 -0400 X-Greylist: delayed 1617 seconds by postgrey-1.27 at vger.kernel.org; Wed, 01 Oct 2014 00:21:37 EDT Received: from socket.bbn.com ([192.1.120.102]:47970) by smtp.bbn.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.77 (FreeBSD)) (envelope-from ) id 1XZB04-0002YA-Ky; Tue, 30 Sep 2014 23:54:48 -0400 X-Submitted: to socket.bbn.com (Postfix) with ESMTPSA id 5B6B0401AF User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 In-Reply-To: Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On 2014-09-30 18:35, Junio C Hamano wrote: > Richard Hansen writes: >> * While this syntax works in both Bash and Zsh (assuming no >> pattern-special characters), my preference is to stick to POSIX[1] >> when possible. > > Nah. The existing script is full of bash-isms like local you > suggested to add (and other constructs like shell arrays and [[ ]] > tests, I suspect), True. > and there is no hope to "fix" them to stick to > the bare-minimum POSIX, I don't think it'd be hard to convert it to pure POSIX if there was a desire to do so. The biggest challenge would be 'local', which would require subshells or uniquified prefixed global variables. Both of those are likely to make the code a bit grotesque. > and there is no need to do so (isn't this > bash-prompt script after all?) It would be unwise to go to great lengths to avoid Bashisms, but I think it would be smart to use POSIX syntax when it is easy to do so. Rarely is it hard or awkward to use POSIX syntax ('local' and arrays are two major exceptions), so Bashisms like the ${//} expansion in this patch are usually unnecessary divergences from a ubiquitous standard. POSIX is a stable foundation, and it's easy to get POSIX shell code to run consistently on all POSIX-like shells. One of these days I'll try converting git-prompt.sh to POSIX -- I'm curious to see how bad it would be. -Richard