on master help sign in
src/output.rs: Handle `less` in a portable way.
commit76df41fa973a4fb1cd4192b0a5865b8c441cdf2c authorAankhen <Aankhen@users.noreply.github.com> dateThu 6 Sep 2018, 19:11 (8 years ago) parent97efd75
1 file changed+7−2
src/output.rs+7−2
src/output.rs+7−2
@@ -1,5 +1,7 @@
11use std::env;
2+use std::ffi::OsString;
23use std::io::{self, Write};
4+use std::path::PathBuf;
35use std::process::{Child, Command, Stdio};
46
57use app::PagingMode;
@@ -26,13 +28,16 @@ impl OutputType {
2628 .or_else(|_| env::var("PAGER"))
2729 .unwrap_or(String::from("less"));
2830
29− let mut process = if pager == "less" || pager.ends_with("/less") {
31+ let less_path = PathBuf::from(&pager);
32+ let is_less = less_path.file_stem() == Some(&OsString::from("less"));
33+
34+ let mut process = if is_less {
3035 let mut args = vec!["--RAW-CONTROL-CHARS", "--no-init"];
3136 if quit_if_one_screen {
3237 args.push("--quit-if-one-screen");
3338 }
3439
35− let mut p = Command::new("less");
40+ let mut p = Command::new(&less_path);
3641 p.args(&args).env("LESSCHARSET", "UTF-8");
3742 p
3843 } else {