Browse Source

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

Respect the `LESS' environment variable.
Matthew Wang 11 years ago
parent
commit
bdb65ad6a1
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      cdiff.py

+ 6
- 2
cdiff.py View File

29
 except NameError:
29
 except NameError:
30
     def next(obj): return obj.next()
30
     def next(obj): return obj.next()
31
 
31
 
32
+import os
32
 import re
33
 import re
33
 import signal
34
 import signal
34
 import subprocess
35
 import subprocess
606
     See issue #30 (https://github.com/ymattw/cdiff/issues/30) for more
607
     See issue #30 (https://github.com/ymattw/cdiff/issues/30) for more
607
     information.
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
     pager = subprocess.Popen(
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
     diffs = DiffParser(stream).get_diff_generator()
617
     diffs = DiffParser(stream).get_diff_generator()
614
     marker = DiffMarker()
618
     marker = DiffMarker()