From: Junio C Hamano Date: Tue, 29 Mar 2011 07:09:14 GMT Subject: Re: [PATCH] Remove "bashism" from contrib/thunderbird-patch-inline/appp.sh Message-ID: <7vei5qtnc5.fsf@alter.siamese.dyndns.org> In-Reply-To: <4D9103D3.5010403@zoho.com> Ángel González writes: > This is wrong. Not really. > You are replacing bash with sh: >> -#!/bin/bash >> +#!/bin/sh > > but the script still uses bash-specific syntax (aka. bashishms): Do you mean some of the parts you quoted are bashism? >> PATCH=$(zenity --file-selection) Even though ancient shells I grew up with did not have $(), it is a way backticks should have been written by Bourne from day one. Historically, handling nesting and interraction between double-quotes and backticks correctly was a nightmare to get right, and different implementations of shells got them always wrong. If you use $(), the headaches go away. These days, we don't know of any POSIX shell that is widely used and does not understand $(). As such, the above construct is perfectly safe and even preferred over ``. Welcome to the 21st century ;-) >> if [ "$?" != "0" ] ; then While I personally do not like this style (I am old fashioned) and would probably write: if test $? != 0 then ... or make it even more readable by writing it together with the previous statement, i.e. PATCH=$(zenity --file-selection) || ... myself, it is definitely not bash-ism to use [] for conditionals. Some people seem to find it more readable than traditional "test" (not me). The only major platform that didn't have a reasonable shell was Solaris, but we already have written its /bin/sh off as broken and unusable, and suggest people to use xpg4 or xpg6 shell (see the Makefile).