about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2016-05-21 12:33:26 +0200
committerhut <hut@lepus.uberspace.de>2016-05-21 12:33:26 +0200
commitc84710880dff3c591019ab235d8021fc259e886a (patch)
treeadd19884150e468f1eb84cf4081dd0df834082dc
parent43cc6c32ce9ae28931c0abb83e6e62c9bb2616d5 (diff)
downloadranger-c84710880dff3c591019ab235d8021fc259e886a.tar.gz
core.linemode: fix crash when `file` fails
-rw-r--r--ranger/core/linemode.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/ranger/core/linemode.py b/ranger/core/linemode.py
index b7aef23f..be559578 100644
--- a/ranger/core/linemode.py
+++ b/ranger/core/linemode.py
@@ -97,8 +97,11 @@ class FileInfoLinemode(LinemodeBase):
 
     def infostring(self, file, metadata):
         if not file.is_directory:
-            from subprocess import check_output
-            fileinfo = check_output(["file", "-bL", file.path]).strip()
+            from subprocess import check_output, CalledProcessError
+            try:
+                fileinfo = check_output(["file", "-bL", file.path]).strip()
+            except CalledProcessError:
+                return "unknown"
             if sys.version_info[0] >= 3:
                 fileinfo = fileinfo.decode("utf-8")
             return fileinfo