mysql2sqlite
mysql2sqlite copied to clipboard
work around mawk's lack of repetition support
mawk does not support brace expressions for repetition. See: https://github.com/ThomasDickey/original-mawk/issues/25
This change works around the problem by just repeating the match group the desired number of times.
You can see the fix in action on the tests in my branch here https://github.com/frrad/mysql2sqlite/pull/3/files.
I also think that it's perfectly justifiable to not support mawk since this is pretty gross. If you decide to go this road though it might be nice to call it out in the README which currently says that mawk "should work"
Thanks for spotting it - I would call it a regression and we shall probably add a unit test for this case (though this unit test shall be conditional to not require each contributor to have mawk installed, but instead issue a warning, that mawk unit tests could not be executed leading to potential issues - type mawk >/dev/null 2>&1 && do_the_mawk_unit_tests...).
Feel free to wait a bit (until I've reviewed the other pulls of yours regarding unit tests :wink:) and then add this mawk warning to unit tests.
Just a though - would it be more readable to construct the regex programatically using a loop in BEGIN{} instead of copy-paste? I'm afraid it wouldn't, but I'm curious what you think.
I think that's actually much nicer (though still not amazing). I've made the change. Commit tested here.