summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2016-09-28 22:35:49 +0200
committernfnty <git@nfnty.se>2017-01-22 02:00:55 +0100
commit79deadc7a9662807c075e3c61f3eb9362e29683c (patch)
tree85d89e211744c81256dd564fb521c3162a4ec1e2
parentc65a61c7db1178201ce2c0118c033f9b8ae43bd1 (diff)
downloadranger-79deadc7a9662807c075e3c61f3eb9362e29683c.tar.gz
core.actions: Split `$PAGER` before running
If `$PAGER` is `less -R`, then `-R` should be an argument.
-rw-r--r--ranger/core/actions.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index baf98563..137e2c1f 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -10,6 +10,7 @@ import os
 from os import link, symlink, getcwd, listdir, stat
 from os.path import join, isdir, realpath, exists
 import re
+import shlex
 import shutil
 import string
 import tempfile
@@ -1200,6 +1201,9 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
     # -- Overview of internals
     # --------------------------
 
+    def _run_pager(self, path):
+        self.run(shlex.split(os.environ.get('PAGER', ranger.DEFAULT_PAGER)) + [path])
+
     def dump_keybindings(self, *contexts):
         if not contexts:
             contexts = 'browser', 'console', 'pager', 'taskview'
@@ -1226,8 +1230,7 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
             write("\n")
 
         temporary_file.flush()
-        pager = os.environ.get('PAGER', ranger.DEFAULT_PAGER)
-        self.run([pager, temporary_file.name])
+        self._run_pager(temporary_file)
 
     def dump_commands(self):
         temporary_file = tempfile.NamedTemporaryFile()
@@ -1252,8 +1255,7 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
                 write("    :%s\n" % cmd.get_name())
 
         temporary_file.flush()
-        pager = os.environ.get('PAGER', ranger.DEFAULT_PAGER)
-        self.run([pager, temporary_file.name])
+        self._run_pager(temporary_file)
 
     def dump_settings(self):
         temporary_file = tempfile.NamedTemporaryFile()
@@ -1265,8 +1267,7 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
             write("%30s = %s\n" % (setting, getattr(self.settings, setting)))
 
         temporary_file.flush()
-        pager = os.environ.get('PAGER', ranger.DEFAULT_PAGER)
-        self.run([pager, temporary_file.name])
+        self._run_pager(temporary_file)
 
     # --------------------------
     # -- File System Operations