GNOME Bugzilla – Bug 743911
yelp-build uses non-portable expr arguments
Last modified: 2015-06-05 18:41:08 UTC
According to POSIX standard (http://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html), 'expr index', 'expr substr', 'expr length', and 'expr match' are not portable because their results are unspecified. This causes a lot of syntax error when yelp-build is run to build libgda-5.2 on FreeBSD.
Created attachment 295996 [details] [review] yelp-build: Implement several non-portable expr commands using shell functions I implement these non-portable functions as a shell function, so we don't need to change all expr usage in the script.
Thanks for reporting this. I fixed up part of this by replacing `expr length` with ${#str}. I really thought that was a bashism, but it seems to be portable. And I got rid of the `expr index` by using ${str#prefix}, which also seems to be portable. In fact, my usage of `expr index` was incorrect to begin with. I was using as if it looks for a substring, but it looks for any of the chars in the second arg. New code should be portable and correct. I still need to fix the `expr substr` usage. I don't see `expr match` used anywhere.
Should all be addressed now in git master. Let me know if there are still any problems.
Thanks, the problem is fixed.