瀏覽代碼

Merge pull request #35 from rakuco/respect-LESS-env-var

Respect the `LESS' environment variable.
Matthew Wang 11 年之前
父節點
當前提交
bdb65ad6a1
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6
    2
      cdiff.py

+ 6
- 2
cdiff.py 查看文件

@@ -29,6 +29,7 @@ try:
29 29
 except NameError:
30 30
     def next(obj): return obj.next()
31 31
 
32
+import os
32 33
 import re
33 34
 import signal
34 35
 import subprocess
@@ -606,9 +607,12 @@ def markup_to_pager(stream, opts):
606 607
     See issue #30 (https://github.com/ymattw/cdiff/issues/30) for more
607 608
     information.
608 609
     """
609
-    # Args stolen from git source: github.com/git/git/blob/master/pager.c
610
+    pager_cmd = ['less']
611
+    if not os.getenv('LESS'):
612
+        # Args stolen from git source: github.com/git/git/blob/master/pager.c
613
+        pager_cmd.extend(['-FRSX'])
610 614
     pager = subprocess.Popen(
611
-        ['less', '-FRSX'], stdin=subprocess.PIPE, stdout=sys.stdout)
615
+        pager_cmd, stdin=subprocess.PIPE, stdout=sys.stdout)
612 616
 
613 617
     diffs = DiffParser(stream).get_diff_generator()
614 618
     marker = DiffMarker()