Re: [RFC] war on echo in scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

>> +echo() {
>> +	printf '%s\n' "$*"
>> +}
>
> As long as we don't have "echo -n" and "echo -e", this should
> work, but...

Yes, it’s ugly.  And it could make for surprises in user scripts.

"echo -n" has been disallowed in core git since v0.99.9m^2~52 (Use
printf rather than echo -n, 2005-12-06).  Some echos seem to
expect '\c' instead.

"echo -e" is not allowed either, to support the Almquist shell
and its descendents; see v1.2.0~4 (avoid echo -e, there are systems
where it does not work, 2006-02-12).

Maybe we can avoid impacting user scripts by making this opt-in?
i.e., something like

 if test -n "$GIT_FIX_ECHO"
 then
	echo() {
		printf '%s\n' "$*"
	}
 fi

I am still not sure about the portability of overriding builtins.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]