Timeline for Msys2 bash rejects empty subexpression in regular expression
Current License: CC BY-SA 4.0
Post Revisions
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| yesterday | vote | accept | Peter - Reinstate Monica | ||
| yesterday | comment | added | Peter - Reinstate Monica | @cas The real expression is used to check for any of a fixed number of keywords with the same meaning ("n", "no", "none", "0", "false" or, which creates the complication, an empty string ) that may be present in a variable, once, in the beginning of the script. I think the use case is totally fine. | |
| yesterday | comment | added | cas | Is this for just a one-off or occasional regex match in your script? If so, using bash regex matches is fine. If not, if you're using it in, say, a while read loop or a for loop, then you really should rewrite that section of the script to use sed or awk or perl. If regex matches are the majority of the script then rewrite the whole thing in either awk or perl, optionally with a shell wrapper. Use shell for what it's good at, and use other tools for what they're good at. | |
| 2 days ago | history | became hot network question | |||
| 2 days ago | comment | added | Peter - Reinstate Monica | @waltinator Thanks for the pointer; shellcheck finds no issue though. | |
| 2 days ago | comment | added | waltinator |
Always paste your script into https://shellcheck.net, a syntax checker, or install shellcheck locally. Make using shellcheck part of your development process.
|
|
| 2 days ago | answer | added | Stéphane Chazelas | timeline score: 9 | |
| 2 days ago | history | asked | Peter - Reinstate Monica | CC BY-SA 4.0 |