pax_global_header00006660000000000000000000000064136613334210014514gustar00rootroot0000000000000052 comment=15ac37279ebd0bc46faea1f07282aaa782061825 txt2regex-0.9/000077500000000000000000000000001366133342100133205ustar00rootroot00000000000000txt2regex-0.9/.travis.yml000066400000000000000000000004161366133342100154320ustar00rootroot00000000000000language: python addons: apt: packages: - shellcheck # shfmt is already available script: - make check - make test-bash - make test-regex # The repository must remain unchanged after the checks - git diff - git diff-index --exit-code HEAD txt2regex-0.9/CHANGELOG.md000066400000000000000000000203431366133342100151330ustar00rootroot00000000000000# Changelog for txt2regex All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog]. [Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ [Unreleased]: https://github.com/aureliojargas/txt2regex/compare/v0.9...HEAD [Version 0.9]: https://github.com/aureliojargas/txt2regex/compare/v0.8...v0.9 [Version 0.8]: https://github.com/aureliojargas/txt2regex/compare/v0.7...v0.8 [Version 0.7]: https://github.com/aureliojargas/txt2regex/compare/v0.6...v0.7 [Version 0.6]: https://github.com/aureliojargas/txt2regex/compare/v0.5...v0.6 [Version 0.5]: https://github.com/aureliojargas/txt2regex/compare/v0.4...v0.5 [Version 0.4]: https://github.com/aureliojargas/txt2regex/compare/v0.3.1...v0.4 [Version 0.3.1]: https://github.com/aureliojargas/txt2regex/compare/v0.3...v0.3.1 [Version 0.3]: https://github.com/aureliojargas/txt2regex/compare/v0.2...v0.3 [Version 0.2]: https://github.com/aureliojargas/txt2regex/compare/v0.1...v0.2 [Version 0.1]: https://github.com/aureliojargas/txt2regex/commit/1a45c22 [#7]: https://github.com/aureliojargas/txt2regex/pull/7 [#6]: https://github.com/aureliojargas/txt2regex/pull/6 [#5]: https://github.com/aureliojargas/txt2regex/pull/5 [#3]: https://github.com/aureliojargas/txt2regex/pull/3 ## [Version 0.9] released in 2020-05-21 ### Added - Added CHICKEN Scheme regexes (thanks Mario Domenech Goulart) - New tests for all the command line options (`tests/cmdline.md`) - New tests for txt2regex features (`tests/features.md`) [#5] - New regex tester that runs the supported programs in a Docker container. Using specially crafted regexes, it verifies how the programs behave in "real life". This avoids manual testing or reading the program documentation to get regex-related information (`tests/regex-tester.sh`) [#6] - New automatic testing in all Bash versions from 3.0 to 5.0, to make sure txt2regex works in all of them (`make test-bash`) - Now using Travis CI to run all the tests at every push to the GitHub repository - New Makefile targets to perform common tasks: `check`, `fmt`, `install-bin`, `install-mo`, `lint`, `test`, `test-bash`, `test-regex`, `test-regex-build`, `test-regex-shell` - Added short options `-h` (for `--help`) and `-V` (for `--version`) ### Removed - Removed Lisp regexes (choose Emacs and/or CHICKEN Scheme instead) - Removed OpenOffice.org regexes (not supported by the new regex tester) - Removed VBScript regexes (not supported by the new regex tester) - Removed the old regex tester `test-suite/*` - Removed `tools/bashdump-rmdup.sh` since `msguniq` has the same functionality - Removed the NEWS file for not adding too much value over the changelog ### Changed - Bumped minimal required Bash version from 2.04 to 3.0 - Bumped the versions for all the supported programs - Validated and updated the regex data for all the supported programs, thanks to the new regex tester. Some programs now support new metacharacters, while others got updates on the escaping rules and POSIX character classes support [#7] - JavaScript regexes: now using Node.js instead of Netscape - lex regexes: now using GNU flex - PHP regexes: switch from old `ereg` to `preg` (PCRE) - Changed the default programs: +egrep +grep +emacs -perl -php -postgres - Remove repeated characters inside a list `[]` (if the user has typed `abbbca`, make it `[abc]`) - Now `--showmeta` also shows the version for each program - Now the "!! not supported" legend only appears when there are unsupported metacharacters in the current regex - Converted everything (code, docs, translations) to UTF-8 - Improved the source code quality (`shellcheck`) and formatting (`shfmt`) - Unset `$PATH` in the top of the script to make sure only Bash builtin commands are used - Simplified the man page contents - i18n: Improve some translatable strings to make them shorter and easier to translate - Moved the project hosting from SourceForge to GitHub - Converted this changelog to the [Keep a Changelog] format ### Fixed - Fixed to work properly in bash5 (thanks Yanmarshus Bachtiar) - Fixed `eval` bug when running in bash3 or newer (thanks Marcus Habermehl) - Fixed incorrect metacharacters for `?` and `+` showing up for `vi` in `--showmeta` and `--showinfo` - Fixed the escaping of the `}` character to be matched as a literal - Fixed the escaping of the `\` character to be matched as a literal, for programs that use `\\` for escaping: before: `\\\`, now: `\\\\` - Fixed the escaping of the `\` character when inside a list `[]` - Fixed the handling of the `[` character when inside a list `[]`: it is not special at all and should not be handled - Fixed the handling of the `^` character when inside a list `[]`: only move it to the end when it is in the first position - Fixed the handling of the `-` character when inside a list `[]`: do not move it to the end when it is in the first position, since it is not special there ### Translations - Added Turkish translations provided by erayalakese [#3] - Added Catalan translations provided by Carles (ChAoS) - Added French translations provided by wwp ## [Version 0.8] released in 2004-09-28 ### Added - Added OpenOffice.org regexes support ### Changed - Documentation updated: cleaner README and new man page contents ### Fixed - Fixed bash version test, now works on bash 3.0 and newer (thanks Rene Engelhard) - Fixed sed script bug on `procmail-re-test` (thanks JulioB @ caltech) ### Translations - Added Romanian translations provided by Robert Claudiu Gheorghe - Added Spanish translations provided by Diego Moya Velázquez - Added Italian translations provided by Daniele Pizzolli and revised by Marco Pagnanini ## [Version 0.7] released in 2002-03-04 ### Added - Groups are now quantifiable, i.e. `(foo|bar){1,5}` - New option `--prog` to choose which programs to show the regexes for - New option `--make` to automatically compose regexes for common patterns: date, hour, number - New option `--version` to show the txt2regex version - Added the "Really quit?" confirmation (thanks Martin Butterwecki) - Added man page (thanks Martin Butterwecki) ### Fixed - Fixed Makefile bug on `DESTDIR` (thanks Martin Butterwecki) ### Translations - Added Japanese translations provided by Hajime Dei ## [Version 0.6] released in 2001-09-05 - Added (group|and|alternation) support - Added groups balance check -> `(((3)))` - Added MySQL regexes support - Option `--history` now supports all the txt2regex features - Added German translations provided by Jan Parthey ## [Version 0.5] released in 2001-08-28 - New option `--showmeta` to print a complete metacharacters table - New option `--showinfo` to print regex-related information about a program ## [Version 0.4] released in 2001-08-02 - Added JavaScript regexes support - Added PostgreSQL regexes support - Added procmail regexes support - Added VBScript regexes support - New `procmail-re-test` utility to test the procmail regexes from the command line - Test-suite improved and now included on the tarball - Updated Polish translations ## [Version 0.3.1] released in 2001-06-26 - Now using a custom `sek()` function instead of the `seq` command, thus removing the last external (non-bash-builtin) command from txt2regex - Updated Indonesian translation - Updated Polish translation ## [Version 0.3] released in 2001-06-13 - Added support for localized POSIX character classes `[[:abc:]]` - Added support for special user combinations inside lists `[]` - New option `--whitebg` to adjust the colors for white background terminals - Improve the final human sentence with more detailed data - Remove the usage of the `clear` and `stty` commands, because they are not Bash builtin commands (and txt2regex strives to be 100% Bash builtins powered) - The project is now hosted at SourceForge - Added Polish translations provided by Chris Piechowicz ## [Version 0.2] released in 2001-04-24 - Changed project name from txt2regexp to txt2regex - New option `--history` to "replay" from history data a regex previously composed in txt2regex - New option `--nocolor` to not use colors in the interface - New dynamic history for user input: `.oO(history)(¤user_input1¤userinput2¤...)` - Added Indonesian (Bahasa) translations provided by Muhamad Faizal ## [Version 0.1] released in 2001-02-23 - Initial release (as txt2regexp) txt2regex-0.9/CONTRIBUTING.md000066400000000000000000000135041366133342100155540ustar00rootroot00000000000000# Contributing to txt2regex Please follow the usual GitHub workflow to contribute to this project: - Use [GitHub issues](https://github.com/aureliojargas/txt2regex/issues) for bug reports and feature requests. - Use GitHub pull requests to submit code and translations. ## Guidelines The following guidelines are reminders for the future me (the author), because I cannot hold all of that information in my head. You, as a contributor, are not required to follow them (but thanks if you do). - Keep the current code style (even if you find it odd) - Keep the code formatted (`make fmt`) and validated (`make lint`) - Do not use any system command, this is a Bash builtins script - Do not use any Bash feature that is not supported by the old minimal version txt2regex supports (see https://mywiki.wooledge.org/BashFAQ/061) - Do not use `echo`, use `printf` - Always use `[` instead of `test` in `txt2regex.sh` - Use `-eq` and `-ne` instead of `==` and `!=` for numeric tests - Use `-n` and `-z` when testing variables for emptiness - Always use `$"..."` for strings that the user will see (i18n) - Think about translations, keep strings short and direct - Update the man page when there are relevant changes - Update the Changelog when there are relevant changes - New files should always be UTF-8 ## Testing All tests must always be successful. The CI will refuse changes that break tests. - Add/update tests in `tests/*.md` when adding/updating features - Make sure all the tests are passing: `make test` - Make sure it's working in all Bash versions: `make test-bash` - When touching the regex tester, run it (`make test-regex`) and check the `regex-tester.txt` contents for changes - Do some manual testing to make sure the interactive usage is ok ## Releasing - Make sure all the tests are passing (see previous topic) - Make sure the manual page contents is up-to-date with the current code and regenerate it with `make doc` - Also update the date at the top to the release date - Make sure the Changelog is up-to-date, containing all the relevant changes since the last released version - In the `TODO` file, is there anything to be added/removed? - In the `README.md` file, is there anything to be added/removed? - Update the `po/*.{po,pot}` files to match the current code: run `make po` and commit - Create the official release commit: - Update the version number in `txt2regex.sh` and `Makefile` - Update the version number and creation date in the potfile: `make pot` - Update the changelog with the version number and release date - Commit - Tag this commit with the version number - Publish the release: `git push && git push --tags` - Get back to the development version: - Update the version number in `txt2regex.sh` and `Makefile` - Use `version+1` and add the `b` suffix (for beta) - Create a new "unreleased" entry in the changelog ## History rewrite In 2020-05-19 the whole Git history for this repository was rewritten. It was necessary to set the correct date for the initial commits, so they reflect the official release date for the releases. Before: 699db55 2012-12-21 adding txt2regex version 0.1 (2001-02-23) fb48115 2012-12-21 Revert "adding txt2regex version 0.1 (2001-02-23)" 1a45c22 2012-12-21 add txt2regex version 0.1 (2001-02-23) 961f8fa 2012-12-21 Program renamed from txt2regexp to txt2regex f4ac6e7 2012-12-21 Add txt2regex version 0.2 (2001-04-24) 4c037d1 2012-12-21 Renamed file: id.po => id_ID.po 7c4de30 2012-12-21 Add txt2regex version 0.3 (2001-06-13) 5d56afd 2012-12-21 Add txt2regex version 0.3.1 (2001-06-26) 92c7677 2012-12-21 Add txt2regex version 0.4 (2001-08-02) cd23c57 2012-12-21 Add txt2regex version 0.5 (2001-08-28) 4b572b5 2012-12-21 Add txt2regex version 0.6 (2001-09-05) 20ac0f5 2012-12-21 Add txt2regex version 0.7 (2002-03-04) 6fe0ae8 2012-12-21 Add txt2regex version 0.8 (2004-09-28) 3bbfa3b 2012-12-21 Add txt2regex version 0.9 beta (unreleased) After: f17f458 2001-02-22 Initial commit 2f066eb 2001-02-22 Remove empty README eff18e0 2001-02-23 Add txt2regex version 0.1 (2001-02-23) 5f685c5 2001-04-24 Program renamed from txt2regexp to txt2regex da3e729 2001-04-24 Add txt2regex version 0.2 (2001-04-24) db8a71e 2001-06-13 Renamed file: id.po => id_ID.po 6fa7545 2001-06-13 Add txt2regex version 0.3 (2001-06-13) 98c60e8 2001-06-26 Add txt2regex version 0.3.1 (2001-06-26) f2acfd3 2001-08-02 Add txt2regex version 0.4 (2001-08-02) bdd05d1 2001-08-28 Add txt2regex version 0.5 (2001-08-28) 7e9159f 2001-09-05 Add txt2regex version 0.6 (2001-09-05) b8b618a 2002-03-04 Add txt2regex version 0.7 (2002-03-04) 8d96c9a 2004-09-28 Add txt2regex version 0.8 (2004-09-28) 2768584 2012-12-21 Add txt2regex version 0.9 beta (unreleased) Note that the initial commit was also fixed, instead of the old weird revert. All of the existing Git tags (`v0.1`, `v0.2`, ...) were updated to point to the new commits. Another change in this rewrite was the removal (not the revert) of the commit that added the `releases/` folder with all the `.tgz` files from all the releases (until v0.8): 2a113fe 2013-09-22 Add new 'releases' folder with TGZ files That was a bad idea. GitHub already provides automatic `.zip` and `.tar.gz` files for every tagged commit. Since all of those first commits were created by expanding the tarballs from the official releases, the GitHub ones should be equal. The old `master` branch was saved as the `master-until-2020-05-19` branch. All the pull requests until number 7 are now referencing not the `master` commits, but those in the `master-until-2020-05-19` branch. I know this is a total mess. I'm sorry for that. But I think having the official dates for the commits of the old versions is important. Now the "Releases" listing in GitHub has the correct dates. txt2regex-0.9/COPYRIGHT000066400000000000000000000432541366133342100146230ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. txt2regex-0.9/Makefile000066400000000000000000000111401366133342100147550ustar00rootroot00000000000000NAME = txt2regex VERSION = 0.9 BASHVERSIONS = 3.0 3.1 3.2 4.0 4.1 4.2 4.3 4.4 5.0 REGEXTESTERIMAGE = aureliojargas/regex-tester:2020-05-09 SCRIPT = $(NAME).sh PODIR = po POTFILE = $(PODIR)/$(NAME).pot DESTDIR = BINDIR = $(DESTDIR)/usr/bin LOCALEDIR = $(DESTDIR)/usr/share/locale MANDIR = $(DESTDIR)/usr/share/man/man1 .PHONY: check check-po clean doc fmt install install-bin \ install-mo lint mo po pot test test-bash test-regex \ test-regex-build test-regex-shell #----------------------------------------------------------------------- # Dev check: lint test fmt: shfmt -w -i 4 -ci -sr $(SCRIPT) tests/regex-tester.sh lint: shellcheck $(SCRIPT) tests/regex-tester.sh shfmt -d -i 4 -ci -sr $(SCRIPT) tests/regex-tester.sh test: clitest.sh sh clitest.sh --progress none README.md tests/*.md # Run the tests in multiple Bash versions, using the official Docker # image https://hub.docker.com/_/bash (each image is ~10MB) test-bash: clitest.sh @for v in $(BASHVERSIONS); do \ printf '\nTesting in Bash version %s\n' $$v; \ docker run --rm -v $$PWD:/code -w /code bash:$$v \ sh clitest.sh --progress none tests/*.md; \ done # Run regex tests for the supported programs, inside a Docker container test-regex: # Explicit pull to make sure all the log messages from the pulling # process appear here, and not when executing the next "docker run", # whose output goes directly to the .txt file. docker image inspect $(REGEXTESTERIMAGE) >/dev/null 2>&1 || \ docker pull $(REGEXTESTERIMAGE) # Test all programs except "vi" docker run --rm -v "$$PWD":/code -w /code $(REGEXTESTERIMAGE) \ tests/regex-tester.sh --skip vi > tests/regex-tester.txt 2>&1 # vi: no stderr redirect to avoid "inappropriate ioctl for device" # vi: docker run -t adds a trailing \r to every line :/ docker run --rm -v "$$PWD":/code -w /code -t $(REGEXTESTERIMAGE) \ tests/regex-tester.sh vi | tr -d '\r' >> tests/regex-tester.txt test-regex-shell: docker run --rm -v "$$PWD":/code -w /code -it $(REGEXTESTERIMAGE) test-regex-build: docker build -t $(REGEXTESTERIMAGE) tests/ clean: rm -f clitest.sh $(NAME) txt2tags.py rm -f messages.mo $(PODIR)/{messages,*.mo,*.tmp,*~} rm -rf $(PODIR)/??/ $(PODIR)/??_??/ rm -f tmp.lex.*.{l,run,yy.c} doc: txt2tags.py python ./txt2tags.py -t man man/txt2regex.t2t python ./txt2tags.py -t html man/txt2regex.t2t clitest.sh: curl -s -L -o $@ \ https://raw.githubusercontent.com/aureliojargas/clitest/master/clitest txt2tags.py: curl -s -L -o $@ \ https://raw.githubusercontent.com/aureliojargas/txt2tags/3.4/txt2tags.py #----------------------------------------------------------------------- # Translation files # # Learn more: http://pology.nedohodnik.net/doc/user/en_US/ch-poformat.html # Example potfile: http://git.savannah.gnu.org/cgit/gawk.git/tree/po/gawk.pot pot: @date=`date '+%Y-%m-%d %H:%M %Z'`; \ ( \ printf '%s\n' '#, fuzzy'; \ printf '%s\n' 'msgid ""'; \ printf '%s\n' 'msgstr ""'; \ printf '"%s"\n' 'Project-Id-Version: $(NAME) $(VERSION)\n'; \ printf '"%s"\n' "POT-Creation-Date: $$date\n"; \ printf '"%s"\n' 'PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n'; \ printf '"%s"\n' 'Last-Translator: FULL NAME \n'; \ printf '"%s"\n' 'MIME-Version: 1.0\n'; \ printf '"%s"\n' 'Content-Type: text/plain; charset=UTF-8\n'; \ printf '"%s"\n' 'Content-Transfer-Encoding: 8bit\n'; \ bash --dump-po-strings $(SCRIPT); \ ) | msguniq --no-wrap --sort-by-file -o $(POTFILE); \ printf '%s was generated\n' $(POTFILE) po: pot @for pofile in $(PODIR)/*.po; do \ printf 'Merging %s...' $$pofile; \ msgmerge --update --sort-by-file --no-wrap --previous \ $$pofile $(POTFILE); \ done; \ printf 'Remember to grep for the fuzzy messages in all .po files\n' mo: @for pofile in $(PODIR)/*.po; do \ printf 'Compiling %s... ' $$pofile; \ msgfmt -o $${pofile%.po}.mo $$pofile && \ echo ok; \ done check-po: @for pofile in $(PODIR)/*.po; do \ printf 'Checking %s...' $$pofile; \ msgfmt --verbose $$pofile || exit 1; \ done #----------------------------------------------------------------------- # Release install: install-mo install-bin install-mo: mo test -d $(LOCALEDIR) || mkdir -p $(LOCALEDIR); \ for mofile in $(PODIR)/*.mo; do \ moinstalldir=$(LOCALEDIR)/`basename $$mofile .mo`/LC_MESSAGES; \ test -d $$moinstalldir || mkdir -p $$moinstalldir; \ install -m644 $$mofile $$moinstalldir/$(NAME).mo; \ done install-bin: test -d $(BINDIR) || mkdir -p $(BINDIR); \ sed -e '/^TEXTDOMAINDIR=/s,=.*,=$(LOCALEDIR),' \ $(SCRIPT) > $(BINDIR)/$(NAME) && \ chmod +x $(BINDIR)/$(NAME) && \ printf '\nProgram "%s" installed. Just run %s\n' \ $(NAME) $(BINDIR)/$(NAME) txt2regex-0.9/README.md000066400000000000000000000140041366133342100145760ustar00rootroot00000000000000## txt2regex — The console regular expression wizard ![](https://aurelio.net/projects/txt2regex/img/screenshot.png) - Author: [Aurelio Jargas](https://aurelio.net/about.html) - License: GPL - First release: 2001-02-23 - Requires: Bash >= 3.0 - Website: https://aurelio.net/projects/txt2regex/ Txt2regex is a regular expression wizard that converts human sentences to regexes. In a simple interactive console interface, the user answer questions and the program builds the regexes for more than 20 flavors like grep, Vim, Emacs, JavaScript, PHP, Python, PostgreSQL. Txt2regex is a one-file shell script made 100% with Bash builtin commands. The only requirement is Bash itself, since no grep, find, sed or any other system commands are used. See [tests/cmdline.md](tests/cmdline.md) for a list of all the available command line options and examples on using them. See [tests/features.md](tests/features.md) for some of the special features txt2regex has to handle user input and compose proper regexes. ## Running Txt2regex is a stand-alone Bash script, it doesn't need to be installed. Just run it: bash txt2regex.sh Making it an executable file, you can run it directly: chmod +x txt2regex.sh ./txt2regex.sh If you want it in [another language][pos] besides English: make install BINDIR=. LOCALEDIR=po LANG=es_ES ./txt2regex ## Supported flavors ```console $ bash txt2regex.sh --showmeta awk + ? | () awk version 20121220 chicken + ? {} | () CHICKEN 4.12.0 ed \+ \? \{\} \| \(\) GNU Ed 1.10 egrep + ? {} | () grep (GNU grep) 3.1 emacs + ? \\{\\} \\| \\(\\) GNU Emacs 25.2.2 expect + ? {} | () expect version 5.45.4 find + ? {} | () find (GNU findutils) 4.7.0-git gawk + ? {} | () GNU Awk 4.1.4 grep \+ \? \{\} \| \(\) grep (GNU grep) 3.1 javascript + ? {} | () node v8.10.0 lex + ? {} | () flex 2.6.4 mawk + ? | () mawk 1.3.3 Nov 1996 mysql + ? {} | () mysql Ver 14.14 Distrib 5.7.29 perl + ? {} | () perl v5.26.1 php + ? {} | () PHP 7.2.24-0ubuntu0.18.04.4 postgres + ? {} | () psql (PostgreSQL) 10.12 procmail + ? | () procmail v3.23pre 2001/09/13 python + ? {} | () Python 3.6.9 sed \+ \? \{\} \| \(\) sed (GNU sed) 4.4 tcl + ? {} | () tcl 8.6 vi \{\} \(\) nvi 1.81.6-13 vim \+ \= \{} \| \(\) VIM - Vi IMproved 8.0 (2016 Sep 12) NOTE: . [] [^] and * are the same on all programs. $ ``` ## Regex tester to gather "real life" data Txt2regex needs to know regex-related information for each flavor it supports. For example: - Which metacharacters are supported? - How to escape a metacharacter to match it literally? - Are POSIX character classes supported? Instead of relying in documentation to get that information, the [tests/regex-tester.sh](tests/regex-tester.sh) script calls the real programs with specially crafted regexes and sample texts, verifying how those programs behave in "real life". To have a trackable and public record, the output of this tester is also saved to this repository, in a readable and grepable plain text file: [tests/regex-tester.txt](tests/regex-tester.txt). Future changes in behavior can be easily detected. ## Testing - `make test` — to run all the tests in the current Bash version on your machine. - `make test-bash` — to run all the tests in all the released Bash versions since 3.0 (requires Docker). - `make test-regex` — to run the regex tester (requires Docker). Check the [Makefile](Makefile) for the details on what gets executed. ## Translators ca Catalan Carles (ChAoS) de_DE German Jan Parthey es_ES Spanish Diego Moya fr_FR French wwp id_ID Indonesian Muhamad Faizal it_IT Italian Daniele Pizzolli ja Japanese Hajime Dei pl_PL Polish Chris Piechowicz pt_BR Portuguese Aurelio Jargas ro_RO Romanian Robert Claudiu Gheorghe tr Turkish erayalakese To translate txt2regex to your language: - translate the [po/txt2regex.pot][potfile] file (in the `msgstr` lines) - save it as `po/XX.po` (where XX is the [two-letter code][iso639] for your language) - submit this new `.po` file in a pull request Check the [current translations][pos] for reference. [potfile]: https://github.com/aureliojargas/txt2regex/blob/master/po/txt2regex.pot [iso639]: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes [pos]: https://github.com/aureliojargas/txt2regex/tree/master/po ## FAQ ### Why? - To try to make simple regexes less painful for beginners. - To have a reliable source for the specific regex syntax and rules from different flavors. - To have coding fun :) ### What is that `` that appears in the regex? That `` represents a literal tab character. When using the regex in the desired external program, remember to change that to a literal tab. This is required by programs that do not support using `\t` as a shortcut for the tab character. ### Why my terminal size (lines/columns) is not detected? Txt2regex uses the environment variables `$LINES` and `$COLUMNS` to get the current terminal size. Make sure you have them exported, otherwise the default 80x25 size will be assumed. To check if the variables are exported, run: ```bash bash -c 'echo $COLUMNS $LINES' ``` If no numbers are shown in the output, a quick fix is running: ```bash export COLUMNS LINES ``` As a permanent fix, add the previous `export` command to a Bash configuration file, such as `~/.bashrc`. txt2regex-0.9/TODO000066400000000000000000000017161366133342100140150ustar00rootroot00000000000000txt2regex TODO: - new programs: expr, oawk, nawk, MKS awk, ruby, bash, java, html5, lua - add support for \ - support for user defined ranges as 0-5, a-f, etc - allow combinations as [A-Z0-9_.#] - more ready-to-use regexes! (ip, email, url) - ~/.txt2regexrc: remember programs, last histories, name REs - negated POSIX|special combination (Choice hack) - empty | check, for things like ^| or (|) - how to capture blanks on Get* (via menu)? User requests: - undo last step (Bence Fejervari @ .hu) - std{in,out} mode to use it with a frontend (Robert-Claudiu Gheorghe @ .com) - interface to feed the programs with the RegEx (Chris Piechowicz @ .au) - on the fly regex test (zentara @ .com) - add other versions of the same program (julioB @ .edu) - easy way for people contribute on program's regexes rules (julioB @ .edu) - escape special chars when **applying** the regex (julioB @ .edu) Extra TODO: - grep TODO txt2regex.sh txt2regex-0.9/man/000077500000000000000000000000001366133342100140735ustar00rootroot00000000000000txt2regex-0.9/man/txt2regex.html000066400000000000000000000145441366133342100167250ustar00rootroot00000000000000 TXT2REGEX

TXT2REGEX

May 21, 2020

NAME

txt2regex -- console regular expression wizard

SYNOPSIS

txt2regex [--nocolor|--whitebg] [--all|--prog programs]

txt2regex --showmeta

txt2regex --showinfo program [--nocolor]

txt2regex --history value [--all|--prog programs]

txt2regex --make label [--all|--prog programs]

DESCRIPTION

txt2regex is a regular expression wizard that converts human sentences to regexes.

In a simple interactive console interface, the user answer questions and txt2regex builds the regexes for more than 20 programs.

https://aurelio.net/projects/txt2regex/

OPTIONS

--all
Select all the available programs. Be aware that the list of available programs is long. You will need a terminal window with more than 40 lines for the user interface to fit. Also make sure that the $LINES shell variable is exported, so txt2regex can detect the current number of available lines.

-h, --help
Print the help message and quit.

--history <value>
Print a regex from the given history data. The history value is shown in the last screen of the wizard, when you quit.

--make <label>
Print a ready regex for the specified label. Inform an empty label to see the list of available labels.

--nocolor
Do not use colors.

--prog <program1,program2,...>
Specify which programs to use, separated by commas. Use --showmeta to see the complete list of available programs.

--showinfo <program>
Print regex-related info about the specified program. Use --nocolor to have a text-only output (no control characters).

--showmeta
Print a metacharacters table featuring all the programs.

-V, --version
Print the program version and quit.

--whitebg
Adjust colors for white background terminals.

EXAMPLES

Using it as a wizard (interactive interface):

txt2regex

Specify a custom selection of programs for the wizard:

txt2regex --prog perl,python,php,javascript

Getting an extensive metacharacters table:

txt2regex --showmeta

Getting regex-related information about sed:

txt2regex --showinfo sed

Replay a regex by using history data:

txt2regex --history '16421¤:01¤:'

Getting handy ready-to-use regexes for common patterns:

txt2regex --make hour
txt2regex --make number3 --prog perl
txt2regex --make date2 --all

WIZARD INTERFACE

+---------------------------------------+
| Top menu                              |
| Group menu                            |
|                                       |
| Regexes of the selected programs      |
| ...                                   |
| ...                                   |
|                                       |
| History                               |
| Prompt                                |
|                                       |
| The question                          |
| The answers                           |
| ...                                   |
| ...                                   |
+---------------------------------------+

WIZARD COMMANDS

. Quit the program (with confirmation)
0 Reset the regular expression
1-9 Answers the questions
* Toggles color ON/OFF
/ Add/remove programs
| Insert an alternation (where allowed)
( Open a new group (where allowed)
) Close the opened group (if any)

BUGS

https://github.com/aureliojargas/txt2regex/issues

AUTHOR

Aurelio Jargas <<verde (a) aurelio net>>

COPYRIGHT

Copyright © 2001-2020 Aurelio Jargas, GNU GPL v2

txt2regex-0.9/man/txt2regex.man000066400000000000000000000077341366133342100165370ustar00rootroot00000000000000.TH "TXT2REGEX" 1 "May 21, 2020" "" .SH NAME .P \fBtxt2regex\fR \-\- console regular expression wizard .SH SYNOPSIS .P \fBtxt2regex\fR [\fB\-\-nocolor\fR|\fB\-\-whitebg\fR] [\fB\-\-all\fR|\fB\-\-prog\fR \fIprograms\fR] .P \fBtxt2regex\fR \fB\-\-showmeta\fR .P \fBtxt2regex\fR \fB\-\-showinfo\fR \fIprogram\fR [\fB\-\-nocolor\fR] .P \fBtxt2regex\fR \fB\-\-history\fR \fIvalue\fR [\fB\-\-all\fR|\fB\-\-prog\fR \fIprograms\fR] .P \fBtxt2regex\fR \fB\-\-make\fR \fIlabel\fR [\fB\-\-all\fR|\fB\-\-prog\fR \fIprograms\fR] .SH DESCRIPTION .P \fBtxt2regex\fR is a regular expression wizard that converts human sentences to regexes. .P In a simple interactive console interface, the user answer questions and \fBtxt2regex\fR builds the regexes for more than 20 programs. .P \fIhttps://aurelio.net/projects/txt2regex/\fR .SH OPTIONS .TP \fB\-\-all\fR Select all the available programs. Be aware that the list of available programs is long. You will need a terminal window with more than 40 lines for the user interface to fit. Also make sure that the \fB$LINES\fR shell variable is exported, so \fBtxt2regex\fR can detect the current number of available lines. .TP \fB\-h\fR, \fB\-\-help\fR Print the help message and quit. .TP \fB\-\-history \fR Print a regex from the given history data. The history value is shown in the last screen of the wizard, when you quit. .TP \fB\-\-make