| Summary: | some bash script doesn't seem to work after build machine update | ||
|---|---|---|---|
| Product: | Community | Reporter: | David Williams <david_williams> |
| Component: | Servers | Assignee: | Eclipse Webmaster <webmaster> |
| Status: | RESOLVED NOT_ECLIPSE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | ccc, pwebster |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
David Williams
I think this has nothing to do with whatever the shebang is set to, (though, I would still like to know why $SHELL is set to /usr/local/bin/committer_shell (it's confusing, but I'm just curious ... as long as it is "bash" :) ... which I see it currently is ... set as a symlink pointing to /bin/bash ). what I have learned about the regex problem is that there seems to be some subtle change in "interpreting" the lines of code. In short, if I change if [[ "$projectname" =~ "(.*)-(.*)-(.*)" ]] to if [[ "$projectname" =~ (.*)-(.*)-(.*) ]] (that is, dropped the quotes surrounding the regex pattern. then the regex expression works as before. I checked, and at least on my red hat system that expression, with no quotes, still works fine. So, I'm not sure exactly what's changed to cause this, or if its a bug, or fixing a bug :) ... but, I didn't just dream up the quotes. In my trusty Bash Cookbook (page 123) they show quotes in their examples. Whoa ... I just checked on my Ubutu system, and there too I can not have the quotes to have that regex expression work ... so, guess not a bug. (Guess I've never executed "promote" on my Ubuntu system ... would have no reason to). Given the above, I think this can be closed as closed as 'invalid' but will leave open for a while, to foster discussion, if there is to be any. Though even if technically an invalid bug, it is certainly a valid impact of the upgrade. But since Ubuntu works the same way, I can't say its a bug in OS or that any thing needs to be changed. Hmm, not sure how to have an actual space in the regex expression ... but, guess that's a general user question, not a bug here. Thanks, I did find some references that mention this change in bash 3.2.2 For example, http://tldp.org/LDP/abs/html/bashver3.html mentions its, gives several reference links, and concludes that you can revert to previous behavior using shopt -s compat31. (As far as I know, there's not reason to set shopt for this for the whole system, unless you get tons of failures due to this ... I myself only have a few scripts to update ... though you might list it in a "FAQ" for the upgrade, if you ever make one?) My redhat system actual uses bash greater than 3.2.2 ... but, guess they set the default to previous behavior?) <quote> The =~ Regular Expression match operator no longer requires quoting of the pattern within [[ ... ]]. Caution In fact, quoting in this context is not advisable as it may cause regex evaluation to fail. Chet Ramey states in the Bash FAQ that quoting explicitly disables regex evaluation. See also the Ubuntu Bug List and Wikinerds on Bash syntax. Setting shopt -s compat31 in a script causes reversion to the original behavior. </quote> Just for closure ... the best technical reference I can find for this issue is the in Chet Ramey's Bash FAQ, at ftp://ftp.cwru.edu/pub/bash/FAQ Too long to quote, but see question E14: E14) Why does quoting the pattern argument to the regular expression matching conditional operator (=~) cause matching to stop working? The advice there, to handle space in patterns, it is best to use an env variable, where you can quote and escape to your hearts content, and it still gets used it regex operator as one string, as usual. So, for example, the best way to right these types of expressions would be similar to PPAT="(.*)\ (.*)\ (.*)" if [[ "${projectname}" =~ $PPAT ]] (if I expected spaces instead of hyphens in hypothetical "projectname") Good luck, I think "not eclipse" is best resolution for this entry. I hope the information helps others transition. Thanks, regexp in bash is nasty ..but this is good to know. I have a few instances of this on various servers. Thanks for the docs. |