From 431d5d81cb2d631cfd2b4d853d641a4544b0c37d Mon Sep 17 00:00:00 2001 From: Lionel Dricot Date: Wed, 23 Mar 2022 16:35:10 +0100 Subject: [PATCH] exiting cleanly if less is not found --- offpunk.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/offpunk.py b/offpunk.py index ee3fdd3..52fc473 100755 --- a/offpunk.py +++ b/offpunk.py @@ -219,10 +219,16 @@ _MAX_CACHE_SIZE = 10 _MAX_CACHE_AGE_SECS = 180 less_version = 0 +if not shutil.which("less"): + print("Please install the pager \"less\" to run Offpunk.") + print("If you wish to use another pager, send your request to offpunk@ploum.eu.") + print("(I’m really curious to hear about people not having \"less\" on their system.)") + sys.exit() return_code = subprocess.run("less --version",shell=True, capture_output=True) output = return_code.stdout.decode() # We get less Version (which is the only integer on the first line) words = output.split("\n")[0].split() +less_version = 0 for w in words: if w.isdigit(): less_version = int(w)