[Gluster-devel] portability

Emmanuel Dreyfus manu at netbsd.org
Thu May 15 13:54:43 UTC 2014


Hi

I have not built master for a while, and now find GNU specific extensions
that are not portable. Since it is not the first time I address them, 
I would like to send a reminder about it:

1) bash-specific syntax
Do not write:
	test $foo == "bar" 
But instead write:
	test $foo = "bar" 

The = operator is POSIX compliant. The == operator works in bash end ksh.

2) GNU sed specific flag
Do not write:
	sed -i 's/foo/bar/' buz
But instead write:
	sed  's/foo/bar/' buz > buz.new && mv buz.new buz

The -i  flags is a GNU extension that is not implemented in BSD sed.

3) GNU make specific syntax
Do not write:
foo.c:	foo.x foo.h
	${RPCGEN} $<
But instead write:
foo.c:	foo.x foo.h
	${RPCGEN} foo.x
Or even:
foo.c:	foo.x foo.h
	${RPCGEN} ${@:.c=.c}

$< does not work everywhere in non GNU make. If I understand 
autoconf doc correctly, it does not work outside of generic rules (.c.o:)


-- 
Emmanuel Dreyfus
manu at netbsd.org



More information about the Gluster-devel mailing list