mattn / mattn/jvgrep

meaning less `-P` option

Open
#43 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
144
Forks
19
PR merge metrics
No merged PRs in 30d

Description

現時点で-P (Perlの正規表現を使う) オプションの実質的な意味がありません。

regexp.Comple() はそもそもPerlとして正規表現をコンパイルしています。
https://github.com/golang/go/blob/release-branch.go1.5/src/regexp/regexp.go#L118 (Compileの実装)
https://github.com/golang/go/blob/release-branch.go1.5/src/regexp/regexp.go#L152-L161 (Compileが呼び出している compilesyntax.Parsesyntax.Compile を実行している)

なので事前に syntax.ParseCompile を実施する意味は、実質的に、まったくありません。

かといって差別化のために CompilePOSIX (ERE相当) を使うと、
こちらは ignorecase が使えなくなったり、オプションの説明と食い違ってしまったりします。

またタイトルとは異なりますが -G オプションも、現在実質的な意味がないように見受けられます。
(basic が定義されているが、使われていないようなので)


1つの案として、こんなのが考えられますが、なんかいまいちしっくり来ません。

  • -G, -P オプションは廃止
  • -E オプションを新設する
  • これが指定された場合 regexp.CompilePOSIX を使用し ERE 相当の動作とする。
  • 逆に -E が指定されなかった場合には、 regexp.Compile を使って BRE 相当の動作とする

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the current handling of the -G, -P, and proposed -E options, then compare it with the referenced Go regexp and syntax implementations. The issue presents several alternatives but does not decide which behavior or interface should replace them. Done would require an agreed option design and corresponding behavior checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.