Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One invocation of expr incorrectly uses /^…/ #1592

Closed
jmarshall opened this issue Mar 29, 2023 · 3 comments · Fixed by #1593
Closed

One invocation of expr incorrectly uses /^…/ #1592

jmarshall opened this issue Mar 29, 2023 · 3 comments · Fixed by #1593

Comments

@jmarshall
Copy link
Member

One of the expr invocations in version.sh produces the following warning from busybox's implementation of expr, as used on e.g. Alpine Linux:

expr: warning: '^\([0-9.]*\)$': using '^' as the first character
of a basic regular expression is not portable; it is ignored

Either this needs the same sort of X treatment as the invocation in Makefile's htslib.map rule has, or apparently these expr patterns are defined to be anchored to the beginning of the string anyway so perhaps the ^ could just be removed.

@jkbonfield
Copy link
Contributor

jkbonfield commented Mar 30, 2023

The mind boggles where else you'd use ^ other than the first character (I guess character classes only), but yes expr is apparently not quite standard. If it's not needed anyway then the solution is trivial. That's the daily new thing learnt :-)

Thanks.

jkbonfield added a commit to jkbonfield/htslib that referenced this issue Mar 30, 2023
@jmarshall
Copy link
Member Author

If ^ is not in a place in the RE that makes it an anchor, then it matches a literal caret.

I think the rationale on that page is saying that there exist historical expr implementations that interpreted it as an anchor despite their own documentation saying that in expr a leading ^ would be a literal caret.

Learning every day indeed 😄

@jkbonfield
Copy link
Contributor

Even just using expr for command line regexp matching is pretty esoteric and old school. :) I was (naively) assuming it'd be more portable and canonical than sed. Hah

daviesrob pushed a commit that referenced this issue Mar 30, 2023
vasudeva8 pushed a commit to vasudeva8/htslib that referenced this issue Mar 31, 2023
daviesrob pushed a commit to daviesrob/htslib that referenced this issue Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants