Fossil SCM

Brought the "Fossil grep vs POSIX grep" doc up to date relative to the [/info/f5f4471323d44a82 | merged grep-enhancements branch].

wyoung 2022-04-11 09:33 trunk
Commit caba4b0188c5bcff02e08801eb5ecb61323b8fd0fef46a8e4c007234ff2707a1
1 file changed +34 -25
+34 -25
--- www/grep.md
+++ www/grep.md
@@ -1,58 +1,67 @@
11
# Fossil grep vs POSIX grep
22
33
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.
55
This document explains the commonalities and divergences between [POSIX
66
`grep`](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html)
77
and Fossil `grep`.
88
99
1010
## Options
1111
12
-Fossil `grep` supports only a small subset of the options specified for
12
+Fossil `grep` implements about half of the options specified for
1313
POSIX `grep`:
1414
1515
| Option | Meaning
1616
|--------|-------------------------------------------------------------
17
+| `-c` | report the count of matches rather than the matched text
1718
| `-i` | ignore case in matches
1819
| `-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`.
2828
2929
* There is no equivalent of `grep -F` to do literal fixed-string
3030
matches only.
31
+
32
+* There is no `-x` option for doing a whole-line match.
3133
3234
* `fossil grep -l` does not do precisely the same thing as POSIX
3335
`grep -l`: it lists checkin ID prefixes, not file names.
3436
3537
* Fossil always gives the line number in its output, which is to say
3638
that it acts like `grep -n`. There is no way to disable the line
3739
number in `fossil grep` output.
3840
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
-
5341
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
5463
5564
5665
## Regular Expression Dialect
5766
5867
Fossil contains a built-in regular expression engine implementing a
5968
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button