{"id":15893758,"url":"https://github.com/chinanf-boy/ripgrep-zh","last_synced_at":"2025-03-20T14:30:43.642Z","repository":{"id":38039619,"uuid":"161267784","full_name":"chinanf-boy/ripgrep-zh","owner":"chinanf-boy","description":"中文翻译:\u003cBurntSushi/ripgrep\u003e 一个面向行的搜索工具 :heart: 校对 ✅","archived":false,"fork":false,"pushed_at":"2022-06-11T01:35:12.000Z","size":233,"stargazers_count":161,"open_issues_count":5,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-01T00:20:03.014Z","etag":null,"topics":["docs","files","rust","searcher","zh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chinanf-boy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-11T02:50:43.000Z","updated_at":"2025-02-18T06:22:12.000Z","dependencies_parsed_at":"2022-08-09T08:47:04.620Z","dependency_job_id":null,"html_url":"https://github.com/chinanf-boy/ripgrep-zh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fripgrep-zh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fripgrep-zh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fripgrep-zh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinanf-boy%2Fripgrep-zh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chinanf-boy","download_url":"https://codeload.github.com/chinanf-boy/ripgrep-zh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244075595,"owners_count":20393979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docs","files","rust","searcher","zh"],"created_at":"2024-10-06T08:13:35.991Z","updated_at":"2025-03-20T14:30:43.147Z","avatar_url":"https://github.com/chinanf-boy.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# BurntSushi/ripgrep [![translate-svg]][translate-list]\n\n\u003c!-- [![explain]][source] --\u003e\n\n[explain]: http://llever.com/explain.svg\n[source]: https://github.com/chinanf-boy/Source-Explain\n[translate-svg]: http://llever.com/translate.svg\n[translate-list]: https://github.com/chinanf-boy/chinese-translate-list\n\n「 ripgrep 是一个面向行的搜索工具 」\n\n[中文](./readme.md) | [english](https://github.com/BurntSushi/ripgrep)\n\n---\n\n## 更新 ✅\n\n\u003c!-- doc-templite START generated --\u003e\n\u003c!-- repo = 'BurntSushi/ripgrep' --\u003e\n\u003c!-- commit = '45d12abbc5f576d3b10ae13dc7410b14400a8d1e' --\u003e\n\u003c!-- time = '2019-04-14' --\u003e\n翻译的原文 | 与日期 | 最新更新 | 更多\n---|---|---|---\n[commit] | ⏰ 2019-04-14 | ![last] | [中文翻译][translate-list]\n\n[last]: https://img.shields.io/github/last-commit/BurntSushi/ripgrep.svg\n[commit]: https://github.com/BurntSushi/ripgrep/tree/45d12abbc5f576d3b10ae13dc7410b14400a8d1e\n\n\u003c!-- doc-templite END generated --\u003e\n\n- [x] readme\n- [x] [指南](./GUIDE.zh.md)\n- [x] [FAQ](./FAQ.zh.md)\n- [x] [`rg -h` v0.10.0 中文](./rg-0.10.0-h.zh.md)\n\n\u003cdetails\u003e\n\n- [x] [grep-regex](./grep-regex/README.zh.md)\n- [x] [globset](./globset/README.zh.md)\n- [x] [ignore](./ignore/README.zh.md)\n- [x] [grep](./grep/README.zh.md)\n- [x] [termcolor](./termcolor/README.zh.md)\n- [x] [grep-cli](./grep-cli/README.zh.md)\n- [x] [grep-PCRE2](./grep-PCRE2/README.zh.md)\n- [x] [grep-searcher](./grep-searcher/README.zh.md)\n- [x] [wincolor](./wincolor/README.zh.md)\n- [x] [grep-printer](./grep-printer/README.zh.md)\n- [x] [grep-matcher](./grep-matcher/README.zh.md)\n\n\u003c/details\u003e\n\n### 贡献\n\n欢迎 👏 勘误/校对/更新贡献 😊 [具体贡献请看](https://github.com/chinanf-boy/chinese-translate-list#贡献)\n\n## 生活\n\n[If help, **buy** me coffee —— 营养跟不上了，给我来瓶营养快线吧! 💰](https://github.com/chinanf-boy/live-need-money)\n\n---\n\n## ripgrep (rg)\n\nripgrep 是一个面向行的搜索工具，它在遵循 gitignore 规则的同时，递归地搜索当前目录以寻找正则表达式模式。ripgrep 在 Windows、MaCOS 和 Linux 上拥有一流的支持，可以下载并使用[每个 release](https://github.com/BurntSushi/ripgrep/releases)二进制文件。 ripgrep 类似于其他流行的搜索工具，如 ag，ACK 和 grep。\n\n[![Linux build status](https://travis-ci.org/BurntSushi/ripgrep.svg)](https://travis-ci.org/BurntSushi/ripgrep)\n[![Windows build status](https://ci.appveyor.com/api/projects/status/github/BurntSushi/ripgrep?svg=true)](https://ci.appveyor.com/project/BurntSushi/ripgrep)\n[![Crates.io](https://img.shields.io/crates/v/ripgrep.svg)](https://crates.io/crates/ripgrep)\n\nMIT 或 [UNLICENSE](http://unlicense.org)的双重许可。\n\n### CHANGELOG\n\n请看[CHANGELOG](https://github.com/BurntSushi/ripgrep/blob/master/CHANGELOG.md)发布历史 - `english`。\n\n### 文档快速链接\n\n- [安装](#installation)\n- [用户指南](GUIDE.zh.md)\n- [常见问题](FAQ.zh.md)\n- [正则式 语法](https://docs.rs/regex/1/regex/#syntax)\n- [配置文件](GUIDE.zh.md#configuration-file)\n- [Shell tab 补全](FAQ.zh.md#ripgrep-%E6%98%AF%E5%90%A6%E6%94%AF%E6%8C%81-shell-tab-%E8%A1%A5%E5%85%A8)\n- [构建](#building)\n\n### 搜索结果快照\n\n[![A screenshot of a sample search with ripgrep](http://burntsushi.net/stuff/ripgrep1.png)](http://burntsushi.net/stuff/ripgrep1.png)\n\n### 各大工具对比例子\n\n此示例搜索整个 Linux 内核源树(运行`make defconfig \u0026\u0026 make -j8`后)，找寻匹配项为`[A-Z]+_SUSPEND`，所有匹配必须是单词。在具有 Intel i7-6900K 3.2GHz 的系统上统计时间，并在启用 SIMD 的情况下编译 ripgrep。\n\n请记住，单一的基准是不够的! 看到我[博客上关于 ripgrep 的博文](http://blog.burntsushi.net/ripgrep/)，其有更多的基准和分析进行了非常详细的比较.\n\n| 工具                                                                                 | 命令                                                    | 行计数         | 时间       |\n| ------------------------------------------------------------------------------------ | ------------------------------------------------------- | -------------- | ---------- |\n| ripgrep(Unicode)                                                                     | `rg -n -w '[A-Z]+_SUSPEND'`                             | 450            | **0.106s** |\n| [git grep](https://www.kernel.org/pub/software/scm/git/docs/git-grep.html)           | `LC_ALL=C git grep -E -n -w '[A-Z]+_SUSPEND'`           | 450            | 0.55       |\n| [The Silver Searcher](https://github.com/ggreer/the_silver_searcher)                 | `ag -w '[A-Z]+_SUSPEND'`                                | 450            | 0.895      |\n| [git grep (Unicode)](https://www.kernel.org/pub/software/scm/git/docs/git-grep.html) | `LC_ALL=en_US.UTF-8 git grep -E -n -w '[A-Z]+_SUSPEND'` | 450            | 2.266s     |\n| [sift](https://github.com/svent/sift)                                                | `sift --git -n -w '[A-Z]+_SUSPEND'`                     | 450            | 3.505s     |\n| [ack](https://github.com/petdance/ack2)                                              | `ack -w '[A-Z]+_SUSPEND'`                               | 一千八百七十八 | 6.823s     |\n| [The Platinum Searcher](https://github.com/monochromegane/the_platinum_searcher)     | `pt -w -e '[A-Z]+_SUSPEND'`                             | 450            | 14.208s    |\n\n(是的，`ack` [会有个](https://github.com/petdance/ack2/issues/445)一[bug](https://github.com/petdance/ack2/issues/14))\n\n这是另一个忽略 gitignore 文件和用白名单搜索的基准。语料库与前面的基准测试相同，传递给每个命令的相同标志，确保它们正在执行相同的工作:\n\n| 工具                                           | 命令                                                              | 行计数 | 时间       |\n| ---------------------------------------------- | ----------------------------------------------------------------- | ------ | ---------- |\n| ripgrep                                        | `rg -L -u -tc -n -w '[A-Z]+_SUSPEND'`                             | 404    | **0.079s** |\n| [ucg](https://github.com/gvansickle/ucg)       | `ucg --type=cc -w '[A-Z]+_SUSPEND'`                               | 390    | 0.163s     |\n| [GNU grep](https://www.gnu.org/software/grep/) | `egrep -R -n --include='*.c' --include='*.h' -w '[A-Z]+_SUSPEND'` | 404    | 0.611s     |\n\n(`ucg` [在存在符号链接时，行为略有不同](https://github.com/gvansickle/ucg/issues/106))\n\n最后，在一个单一的大文件(~9.3GB)上，ripgrep 和 GNU grep 之间的直接比较。[`OpenSubtitles2016.raw.en.gz`](http://opus.lingfil.uu.se/OpenSubtitles2016/mono/OpenSubtitles2016.raw.en.gz):\n\n| 工具                                           | 命令                                    | 线路计数 | 时间       |\n| ---------------------------------------------- | --------------------------------------- | -------- | ---------- |\n| ripgrep                                        | `rg -w 'Sherlock [A-Z]\\w+'`             | 5268     | **2.108s** |\n| [GNU grep](https://www.gnu.org/software/grep/) | `LC_ALL=C egrep -w 'Sherlock [A-Z]\\w+'` | 5268     | 7.014s     |\n\n在上述基准中，传递`-n`标志(用于显示行号)，会增加时间，`2.640s`的 ripgrep 和`10.277s`的 GNU grep.\n\n### 为什么我应该使用 ripgrep?\n\n- 它可以替换由其他搜索工具提供的许多用例，因为它包含它们的大部分特性，并且通常更快。(见[FAQ](FAQ.zh.md#posix4ever)有关 ripgrep 是否能够真正取代 grep 的更多细节。\n- 像其他专门用于代码搜索的工具一样，ripgrep 默认用于递归目录搜索，并且不会搜索被`.gitignore`匹配的文件/+夹。默认情况下，它也忽略了隐藏文件和二进制文件。ripgrep 还实现了对`.gitignore`支持，然而，在其它代码搜索工具中，有许多与该功能相关的 bug 工具，声称提供了相同的功能。\n- ripgrep 可以搜索特定类型的文件。例如，`rg -tpy foo`将搜索限制为 Python 文件，`rg -Tjs foo`从搜索中排除 JavaScript 文件 。ripgrep 可以用自定义匹配规则教给新的文件类型。\n- ripgrep 支持许多`grep`特性。例如，显示搜索结果的上下文、搜索多个模式、突出显示具有颜色和全部 Unicode 支持的匹配与 GNU grep 不同，ripgrep 在支持 Unicode(总是在 启动)的同时保持快速。\n- ripgrep 有可选的支持，以切换其正则表达式引擎使用 PCRE2 。除此之外，这使得在模式中，使用环视和反向引用成为可能，而这些在 ripgrep 的默认正则表达式引擎中不受支持。启用 PCRE2 支持用`-P`。\n- ripgrep 支持以 UTF-8 以外的文本编码搜索文件，例如 UTF-16， latin-1， GBK， EUC-JP， Shift_JIS 等等。提供了自动检测 UTF 16 的一些支持。其他文本编码必须与`-E/--encoding`参数搭配使用)\n- ripgrep 支持搜索通用格式(gzip、xz、lzma、bzip2 或 lz4)的压缩文件，搭配`-z/--search-zip`参数.\n- ripgrep 支持任意的输入预处理过滤器，这些过滤器可以是 PDF 文本提取、较少支持的解压缩、解密、自动编码检测等。\n\n换句话说，如果你喜欢速度，默认的过滤，更少的 bug 和 Unicode 支持，使用 ripgrep。\n\n### 为什么我不用 ripgrep?\n\n尽管最初不希望将每个特性都添加到 ripgrep 中，但是随着时间的推移，ripgrep 对其他文件搜索工具中的大多数特性的支持不断增加。这包括搜索跨越多行的结果，以及对 PCRE2 的 opt-in 支持，PCRE2 提供环视和反引号支持。\n\n\u003e 译者: [环视: 在知乎找了个说明文](https://zhuanlan.zhihu.com/p/50789818)\n\n此时，不使用 ripgrep 的主要原因可能包括以下一个或多个:\n\n- 你需要一个便携的无所不在的工具。尽管 ripgrep 在 Windows、macOS 和 Linux 上工作，但它并不普遍，也不符合 POSIX 等任何标准.做这项工作最好的工具是老 grep。\n- 在这个 README 中仍然有一些您心目中所依赖的其他特性(或 bug)没有列出，这些东东在其他工具中，而不在 ripgrep 。\n- 有一个性能边缘情况，ripgrep 做得不好（而在其他工具做得好的地方）。(请提交 bug 报告!)\n- ripgrep 不可能安装在您的机器上，或者不适用于您的平台.(请提交 bug 报告!)\n\n### 真的超越所有?\n\n一般来说，是的。大量的基准，每一个都有详细的分析.[尽在我的博客上](http://blog.burntsushi.net/ripgrep/).\n\n总之，ripgrep 很快，因为:\n\n- 它建在[Rust's regex 引擎](https://github.com/rust-lang-nursery/regex)。 Rust 的正则表达式引擎使用有限自动机、SIMD 和积极的文字优化来使搜索非常快。(PCRE2 支持可以与`-P/--PCRE2`参数)\n- Rust 的 regex 库通过将 UTF-8 解码直接构建到其确定性有限自动机引擎中，从而在完全 Unicode 支持下，保持性能。\n- 它支持使用内存映射，或通过使用中间缓冲区递增地搜索进行搜索。前者对于单个文件更好，后者对于大目录更好。ripgrep 自动为您选择最佳搜索策略。\n- 将您的`.gitignore`文件的忽略模式，应用了一个[`RegexSet`](https://docs.rs/regex/1/regex/struct.RegexSet.html)。 这意味着单个文件路径，可以同时匹配多个 glob 模式。\n- 它使用一个无锁的并行递归目录迭代器[`crossbeam`](https://docs.rs/crossbeam)和[`ignore`](https://docs.rs/ignore)。\n\n### 功能 比较\n\nAndy Lester，[ack](https://beyondgrep.com/)作者已发布了一个比较 ack、ag、git-grep、GNU grep 和 ripgrep 特性的优秀表:\u003chttps://beyondgrep.com/feature-comparison/\u003e\n\n请注意，ripgrep 最近增加了一些尚未出现在 Andy 表中的重要新特性。这包括但不限于，配置文件、passthru、对搜索压缩文件的支持、多行搜索和通过 PCRE2 支持选择高级正则表达式。\n\n### Installation\n\n- 安装\n\nripgrep 的二进制名是`rg`。\n\n**[Windows，macOS 和 Linux 的 二进制文件，尽在于此](https://github.com/BurntSushi/ripgrep/releases)**，若以下有用户的平台没提到的，建议下载这些压缩中的一个。\n\nLinux 二进制文件是静态可执行文件。Windows 二进制文件可用 MinGW(GNU)或微软 Visual C++(MSVC)构建。如果可能的话，更喜欢 MSVC 超过 GNU，但是你需要安装有[Microsoft VC++ 2015\nredistributable](https://www.microsoft.com/en-us/download/details.aspx?id=48145)。\n\n如果你是**macOS Homebrew**或 一个**Linuxbrew**用户，然后可以从 homebrew-core 安装 ripgrep，(用 Rust 稳定版编译，没有 SIMD 支持):\n\n```\n$ brew install ripgrep\n```\n\n或者您可以通过使用定制的 tab 来安装，用 rust nightly 版本 编译的二进制文件(包括 SIMD 和所有优化):\n\n```\n$ brew tap burntsushi/ripgrep https://github.com/BurntSushi/ripgrep.git\n$ brew install ripgrep-bin\n```\n\n如果你是**MacPorts**用户，然后可以从[官方 ports](https://www.macports.org/ports.php?by=name\u0026substr=ripgrep)下载 ripgrep:\n\n```\n$ sudo port install ripgrep\n```\n\n如果你是**Windows Chocolatey**用户，然后可以从[官方 repo](https://chocolatey.org/packages/ripgrep):\n\n```\n$ choco install ripgrep\n```\n\n如果你是**Windows Scoop**用户，然后可以从[官方 bucket](https://github.com/lukesampson/scoop/blob/master/bucket/ripgrep.json):\n\n```\n$ scoop install ripgrep\n```\n\n如果你是一个**Arch Linux**用户，然后您可以从官方，安装 ripgrep :\n\n```\n$ pacman -S ripgrep\n```\n\n如果你是 **Gentoo** 用户，可以从[官方 repo](https://packages.gentoo.org/packages/sys-apps/ripgrep):\n\n```\n$ emerge sys-apps/ripgrep\n```\n\n如果你是 **Fedora 27 +** 用户，可以从官方存储库安装 ripgrep.\n\n```\n$ sudo dnf install ripgrep\n```\n\n如果你是 **Fedora 24 +** 用户，可以从[copr](https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/)安装 ripgrep:\n\n```\n$ sudo dnf copr enable carlwgeorge/ripgrep\n$ sudo dnf install ripgrep\n```\n\n如果你是一个**openSUSE Tumbleweed**用户，可以从[官方 repo](http://software.opensuse.org/package/ripgrep):\n\n```\n$ sudo zypper install ripgrep\n```\n\n如果你是**RHEL/CentOS 7**用户，可以从[copr](https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/)安装 ripgrep:\n\n```\n$ sudo yum-config-manager --add-repo=https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/repo/epel-7/carlwgeorge-ripgrep-epel-7.repo\n$ sudo yum install ripgrep\n```\n\n如果你是**Nix**用户，可以从[nixpkgs](https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/text/ripgrep/default.nix)安装 ripgrep:\n\n```\n$ nix-env --install ripgrep\n$ # (Or using the attribute name, which is also ripgrep.)\n```\n\n如果你是**Debian**用户(或 **Ubuntu** 的用户)，然后，可以使用每一个[ripgrep release](https://github.com/BurntSushi/ripgrep/releases)提供的二进制`.deb`文件来安装 ripgrep。\n\n```\n$ curl -LO https://github.com/BurntSushi/ripgrep/releases/download/0.10.0/ripgrep_0.10.0_amd64.deb\n$ sudo dpkg -i ripgrep_0.10.0_amd64.deb\n```\n\n如果运行 **Debian Buster(当前 Debian 测试)或 Debian SID**，ripgrep 是[Debian 官方包所具备的](https://tracker.debian.org/pkg/rust-ripgrep).\n\n```\n$ sudo apt-get install ripgrep\n```\n\n如果你是一个**Ubuntu Cosmic(18.10)**(或更新的)用户，ripgrep[与上面相同](https://launchpad.net/ubuntu/+source/rust-ripgrep)，是可以使用与 Debian 包装:\n\n```\n$ sudo apt-get install ripgrep\n```\n\n(N.B.Ubuntu 上 ripgrep 的各种快照包也是可用的，但是它们似乎都不能正常工作，并且生成许多非常奇怪的 bug 报告，我不知道如何修复，也没有时间修复)。因此，它**不再是推荐的安装选项**。\n\n如果你是**FreeBSD**用户，然后可以从[官方 ports](https://www.freshports.org/textproc/ripgrep/)安装:\n\n```\n# pkg install ripgrep\n```\n\n如果你是一个**OpenBSD**用户，然后可以从[官方 ports](http://openports.se/textproc/ripgrep)安装:\n\n```\n$ doas pkg_add ripgrep\n```\n\n如果你是**NetBSD**用户，然后可以从[pkgsrc](http://pkgsrc.se/textproc/ripgrep)安装 ripgrep:\n\n```\n# pkgin install ripgrep\n```\n\n如果你是**Rust 程序员** 可以用`cargo`安装 ripgrep.\n\n- 请注意，ripgrep 的最小 Rust 支持版本的是**1.23.0**，虽然 ripgrep 可能与旧版本一起工作。\n- 请注意，二进制可能大于预期，因为它包含调试符号。这是故意的。若要删除调试符号，并减少文件大小，请运行二进制的`strip`。\n\n```\n$ cargo install ripgrep\n```\n\n当使用 Rust 1.27 或更新版本进行编译时，这将自动启用搜索的 SIMD 优化。\n\nripgrep 目前不在任何其他包库中。[我更喜欢这样](https://github.com/BurntSushi/ripgrep/issues/10).\n\n### Building\n\n- 构建\n\nripgrep 是用 Rust 编写的，所以你需要先具有一个[Rust](https://www.rust-lang.org/)。ripgrep 与 Rust 1.28.0(稳定)或打上。一般来说，ripgrep 会跟随 Rust 编译器的最新稳定版本.\n\n构建 ripgrep:\n\n```\n$ git clone https://github.com/BurntSushi/ripgrep\n$ cd ripgrep\n$ cargo build --release\n$ ./target/release/rg --version\n0.1.3\n```\n\n如果您有一个 Rust 夜间(nightly)编译器和最近的 Intel CPU，那么您可以启用额外的可选 SIMD 加速，如下所示:\n\n```\nRUSTFLAGS=\"-C target-cpu=native\" cargo build --release --features 'simd-accel avx-accel'\n```\n\n如果您的机器不支持 AVX 指令，则只需从功能列表中删除`avx-accel`。SIMD 也类似(它大致对应于 SSE 指令)。\n\n在某些 ripgrep 依赖项中，`simd-accel`和`avx-accel`功能会支持 SIMD(负责计算行数和转码)。它们不需要获得 SIMD 优化搜索; 那些是自动启用。希望有一天，`simd-accel`和`avx-accel`特征变得不必要。\n\n最后，可选择加入 PCRE2 的支持，此为通过启用`PCRE2`功能参与 ripgrep 的构建:\n\n```\n$ cargo build --release --features 'PCRE2'\n```\n\n(提示:使用`--features 'PCRE2 simd-accel avx-accel'`还包括编译时 SIMD 优化，这将只适用于夜间编译器。\n\n启用 PCRE2 特性可以与稳定的 Rust 编译器一起工作，并将尝试通过`pkg-config`自动查找，并链接到系统的 PCRE2 库。 如果不存在，那么 ripgrep 将使用系统的 C 编译器，从源代码构建 PCRE2，然后静态地将其链接到最终的可执行文件中。即使存在可用的 PCRE2 系统库，也可以通过构建具有 MUSL 目标的 ripgrep ，或通过设置强制静态链接`PCRE2_SYS_STATIC=1`。\n\n在 Linux 上，能以 MUSL 为目标，构建 ripgrep ，通过在您的系统上先安装 MUSL 库(咨询您友好的邻居 - 包管理器)。然后，您只需要将 MUSL 支持，添加到 Rust 工具链，并重新构建 ripgrep，它就会生成一个完全静态的可执行文件:\n\n```\n$ rustup target add x86_64-unknown-linux-musl\n$ cargo build --release --target x86_64-unknown-linux-musl\n```\n\n应用上面的`--features`参数，就会如愿以偿。如果您想用 MUSL 和 PCRE2 构建静态可执行文件，那么您将需要已安装`musl-gcc`，它可能位于与实际 MUSL 库分隔的包中，这取决于您的 Linux 发行版。\n\n### Running tests\n\n- 运行测试\n\nripgrep 的测试相对不错，包括单元测试和集成测试。若要运行完整的测试套件，请使用:\n\n```\n$ cargo test --all\n```\n\n位于存储库的根目录。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinanf-boy%2Fripgrep-zh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchinanf-boy%2Fripgrep-zh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinanf-boy%2Fripgrep-zh/lists"}