After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 743911 - yelp-build uses non-portable expr arguments
yelp-build uses non-portable expr arguments
Status: RESOLVED FIXED
Product: yelp-tools
Classification: Core
Component: yelp-build
git master
Other FreeBSD
: Normal normal
: ---
Assigned To: Yelp maintainers
Yelp maintainers
Depends on:
Blocks:
 
 
Reported: 2015-02-03 08:01 UTC by Ting-Wei Lan
Modified: 2015-06-05 18:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
yelp-build: Implement several non-portable expr commands using shell functions (2.42 KB, patch)
2015-02-03 08:04 UTC, Ting-Wei Lan
none Details | Review

Description Ting-Wei Lan 2015-02-03 08:01:52 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.
Comment 1 Ting-Wei Lan 2015-02-03 08:04:32 UTC
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.
Comment 2 Shaun McCance 2015-06-01 03:59:10 UTC
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.
Comment 3 Shaun McCance 2015-06-01 15:05:30 UTC
Should all be addressed now in git master. Let me know if there are still any problems.
Comment 4 Ting-Wei Lan 2015-06-05 18:41:08 UTC
Thanks, the problem is fixed.