Fossil SCM
Brought the "Fossil grep vs POSIX grep" doc up to date relative to the [/info/f5f4471323d44a82 | merged grep-enhancements branch].
Commit
caba4b0188c5bcff02e08801eb5ecb61323b8fd0fef46a8e4c007234ff2707a1
Parent
0dd4118063d3c13…
1 file changed
+34
-25
+34
-25
| --- www/grep.md | ||
| +++ www/grep.md | ||
| @@ -1,58 +1,67 @@ | ||
| 1 | 1 | # Fossil grep vs POSIX grep |
| 2 | 2 | |
| 3 | 3 | As of Fossil 2.7, there is a `grep` command which acts roughly like |
| 4 | -POSIX's `grep -E` over all historical versions of a single file name. | |
| 4 | +POSIX's `grep -E` over all historical versions of one or more managed files. | |
| 5 | 5 | This document explains the commonalities and divergences between [POSIX |
| 6 | 6 | `grep`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html) |
| 7 | 7 | and Fossil `grep`. |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | ## Options |
| 11 | 11 | |
| 12 | -Fossil `grep` supports only a small subset of the options specified for | |
| 12 | +Fossil `grep` implements about half of the options specified for | |
| 13 | 13 | POSIX `grep`: |
| 14 | 14 | |
| 15 | 15 | | Option | Meaning |
| 16 | 16 | |--------|------------------------------------------------------------- |
| 17 | +| `-c` | report the count of matches rather than the matched text | |
| 17 | 18 | | `-i` | ignore case in matches |
| 18 | 19 | | `-l` | list a checkin ID prefix for matching historical versions of the file |
| 19 | -| `-v` | print each checkin ID considered, regardless of whether it matches | |
| 20 | - | |
| 21 | -That leaves many divergences at the option level from POSIX `grep`: | |
| 22 | - | |
| 23 | -* There is no built-in way to get a count of matches, as with | |
| 24 | - `grep -c`. | |
| 25 | - | |
| 26 | -* You cannot give more than one pattern, as with `grep -e` or | |
| 27 | - `grep -f`. | |
| 20 | +| `-q` | no output; return only a status code indicating the success of the match | |
| 21 | +| `-s` | suppress error output about missing files | |
| 22 | +| `-v` | invert the sense of the match | |
| 23 | + | |
| 24 | +That leaves several divergences at the option level from POSIX `grep`: | |
| 25 | + | |
| 26 | +* You cannot give more than one pattern, as with `grep -e` or | |
| 27 | + `grep -f`. | |
| 28 | 28 | |
| 29 | 29 | * There is no equivalent of `grep -F` to do literal fixed-string |
| 30 | 30 | matches only. |
| 31 | + | |
| 32 | +* There is no `-x` option for doing a whole-line match. | |
| 31 | 33 | |
| 32 | 34 | * `fossil grep -l` does not do precisely the same thing as POSIX |
| 33 | 35 | `grep -l`: it lists checkin ID prefixes, not file names. |
| 34 | 36 | |
| 35 | 37 | * Fossil always gives the line number in its output, which is to say |
| 36 | 38 | that it acts like `grep -n`. There is no way to disable the line |
| 37 | 39 | number in `fossil grep` output. |
| 38 | 40 | |
| 39 | -* There is no way to suppress all output, returning only a status code | |
| 40 | - to indicate whether the pattern matched, as with `grep -q`. | |
| 41 | - | |
| 42 | -* There is no way to suppress error output, as with `grep -s`. | |
| 43 | - | |
| 44 | -* Fossil `grep` does not accept a directory name for Fossil to | |
| 45 | - expand to the set of all files under that directory. This means | |
| 46 | - Fossil `grep` has no equivalent of the common POSIX `grep -R` | |
| 47 | - extension. (And if it did, it would probably have a different | |
| 48 | - option letter, since `-R` in Fossil has a different meaning, by | |
| 49 | - convention.) | |
| 50 | - | |
| 51 | -* You cannot invert the match, as with `grep -v`. | |
| 52 | - | |
| 53 | 41 | Patches to remove those limitations will be thoughtfully considered. |
| 42 | + | |
| 43 | +Fossil `grep` doesn’t support any of the GNU and BSD `grep` extensions. | |
| 44 | +For instance, it doesn’t support the common `-R` extension to POSIX, | |
| 45 | +which would presumably search a subtree of managed files. If Fossil does | |
| 46 | +one day get this feature, it would have a different option letter, since | |
| 47 | +`-R` in Fossil has a different meaning, by convention. Until then, you | |
| 48 | +can get the same effect on systems with a POSIX shell like so: | |
| 49 | + | |
| 50 | + $ fossil grep COMMAND: $(fossil ls src) | |
| 51 | + | |
| 52 | +If you run that in a check-out of the [Fossil self-hosting source | |
| 53 | +repository][fshsr], that returns the first line of the built-in | |
| 54 | +documentation for each Fossil command, across all historical verisons. | |
| 55 | + | |
| 56 | +Fossil `grep` has extensions relative to these other `grep` standards, | |
| 57 | +such as `--verbose` to print each checkin ID considered, regardless of | |
| 58 | +whether it matches. This one is noteworthy here because the behavior | |
| 59 | +used to be under `-v` before we reassigned it to give POSIX-like `grep | |
| 60 | +-v` behavior. | |
| 61 | + | |
| 62 | +[fshsr]: ./selfhost.wiki | |
| 54 | 63 | |
| 55 | 64 | |
| 56 | 65 | ## Regular Expression Dialect |
| 57 | 66 | |
| 58 | 67 | Fossil contains a built-in regular expression engine implementing a |
| 59 | 68 |
| --- www/grep.md | |
| +++ www/grep.md | |
| @@ -1,58 +1,67 @@ | |
| 1 | # Fossil grep vs POSIX grep |
| 2 | |
| 3 | As of Fossil 2.7, there is a `grep` command which acts roughly like |
| 4 | POSIX's `grep -E` over all historical versions of a single file name. |
| 5 | This document explains the commonalities and divergences between [POSIX |
| 6 | `grep`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html) |
| 7 | and Fossil `grep`. |
| 8 | |
| 9 | |
| 10 | ## Options |
| 11 | |
| 12 | Fossil `grep` supports only a small subset of the options specified for |
| 13 | POSIX `grep`: |
| 14 | |
| 15 | | Option | Meaning |
| 16 | |--------|------------------------------------------------------------- |
| 17 | | `-i` | ignore case in matches |
| 18 | | `-l` | list a checkin ID prefix for matching historical versions of the file |
| 19 | | `-v` | print each checkin ID considered, regardless of whether it matches |
| 20 | |
| 21 | That leaves many divergences at the option level from POSIX `grep`: |
| 22 | |
| 23 | * There is no built-in way to get a count of matches, as with |
| 24 | `grep -c`. |
| 25 | |
| 26 | * You cannot give more than one pattern, as with `grep -e` or |
| 27 | `grep -f`. |
| 28 | |
| 29 | * There is no equivalent of `grep -F` to do literal fixed-string |
| 30 | matches only. |
| 31 | |
| 32 | * `fossil grep -l` does not do precisely the same thing as POSIX |
| 33 | `grep -l`: it lists checkin ID prefixes, not file names. |
| 34 | |
| 35 | * Fossil always gives the line number in its output, which is to say |
| 36 | that it acts like `grep -n`. There is no way to disable the line |
| 37 | number in `fossil grep` output. |
| 38 | |
| 39 | * There is no way to suppress all output, returning only a status code |
| 40 | to indicate whether the pattern matched, as with `grep -q`. |
| 41 | |
| 42 | * There is no way to suppress error output, as with `grep -s`. |
| 43 | |
| 44 | * Fossil `grep` does not accept a directory name for Fossil to |
| 45 | expand to the set of all files under that directory. This means |
| 46 | Fossil `grep` has no equivalent of the common POSIX `grep -R` |
| 47 | extension. (And if it did, it would probably have a different |
| 48 | option letter, since `-R` in Fossil has a different meaning, by |
| 49 | convention.) |
| 50 | |
| 51 | * You cannot invert the match, as with `grep -v`. |
| 52 | |
| 53 | Patches to remove those limitations will be thoughtfully considered. |
| 54 | |
| 55 | |
| 56 | ## Regular Expression Dialect |
| 57 | |
| 58 | Fossil contains a built-in regular expression engine implementing a |
| 59 |
| --- www/grep.md | |
| +++ www/grep.md | |
| @@ -1,58 +1,67 @@ | |
| 1 | # Fossil grep vs POSIX grep |
| 2 | |
| 3 | As of Fossil 2.7, there is a `grep` command which acts roughly like |
| 4 | POSIX's `grep -E` over all historical versions of one or more managed files. |
| 5 | This document explains the commonalities and divergences between [POSIX |
| 6 | `grep`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html) |
| 7 | and Fossil `grep`. |
| 8 | |
| 9 | |
| 10 | ## Options |
| 11 | |
| 12 | Fossil `grep` implements about half of the options specified for |
| 13 | POSIX `grep`: |
| 14 | |
| 15 | | Option | Meaning |
| 16 | |--------|------------------------------------------------------------- |
| 17 | | `-c` | report the count of matches rather than the matched text |
| 18 | | `-i` | ignore case in matches |
| 19 | | `-l` | list a checkin ID prefix for matching historical versions of the file |
| 20 | | `-q` | no output; return only a status code indicating the success of the match |
| 21 | | `-s` | suppress error output about missing files |
| 22 | | `-v` | invert the sense of the match |
| 23 | |
| 24 | That leaves several divergences at the option level from POSIX `grep`: |
| 25 | |
| 26 | * You cannot give more than one pattern, as with `grep -e` or |
| 27 | `grep -f`. |
| 28 | |
| 29 | * There is no equivalent of `grep -F` to do literal fixed-string |
| 30 | matches only. |
| 31 | |
| 32 | * There is no `-x` option for doing a whole-line match. |
| 33 | |
| 34 | * `fossil grep -l` does not do precisely the same thing as POSIX |
| 35 | `grep -l`: it lists checkin ID prefixes, not file names. |
| 36 | |
| 37 | * Fossil always gives the line number in its output, which is to say |
| 38 | that it acts like `grep -n`. There is no way to disable the line |
| 39 | number in `fossil grep` output. |
| 40 | |
| 41 | Patches to remove those limitations will be thoughtfully considered. |
| 42 | |
| 43 | Fossil `grep` doesn’t support any of the GNU and BSD `grep` extensions. |
| 44 | For instance, it doesn’t support the common `-R` extension to POSIX, |
| 45 | which would presumably search a subtree of managed files. If Fossil does |
| 46 | one day get this feature, it would have a different option letter, since |
| 47 | `-R` in Fossil has a different meaning, by convention. Until then, you |
| 48 | can get the same effect on systems with a POSIX shell like so: |
| 49 | |
| 50 | $ fossil grep COMMAND: $(fossil ls src) |
| 51 | |
| 52 | If you run that in a check-out of the [Fossil self-hosting source |
| 53 | repository][fshsr], that returns the first line of the built-in |
| 54 | documentation for each Fossil command, across all historical verisons. |
| 55 | |
| 56 | Fossil `grep` has extensions relative to these other `grep` standards, |
| 57 | such as `--verbose` to print each checkin ID considered, regardless of |
| 58 | whether it matches. This one is noteworthy here because the behavior |
| 59 | used to be under `-v` before we reassigned it to give POSIX-like `grep |
| 60 | -v` behavior. |
| 61 | |
| 62 | [fshsr]: ./selfhost.wiki |
| 63 | |
| 64 | |
| 65 | ## Regular Expression Dialect |
| 66 | |
| 67 | Fossil contains a built-in regular expression engine implementing a |
| 68 |