Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meaning less -P option #43

Open
koron opened this issue Dec 22, 2015 · 1 comment
Open

meaning less -P option #43

koron opened this issue Dec 22, 2015 · 1 comment

Comments

@koron
Copy link
Collaborator

koron commented Dec 22, 2015

現時点で-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 相当の動作とする
@mattn
Copy link
Owner

mattn commented Dec 22, 2015

どれも experimental のまま放置した機能なので削っていいかと思います。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants