From 5dba86dfa258b1019169e04798ad742f429b6edc Mon Sep 17 00:00:00 2001 From: Knight Date: Fri, 17 Jun 2016 21:54:44 +0800 Subject: [PATCH] dircolors: extract shell name from $SHELL properly --- src/dircolors/dircolors.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dircolors/dircolors.rs b/src/dircolors/dircolors.rs index 834f64fbe..6fd82f336 100644 --- a/src/dircolors/dircolors.rs +++ b/src/dircolors/dircolors.rs @@ -36,11 +36,12 @@ pub enum OutputFmt { } pub fn guess_syntax() -> OutputFmt { - use std::path; + use std::path::Path; match env::var("SHELL") { Ok(ref s) if !s.is_empty() => { - if let Some(last) = s.rsplit(path::MAIN_SEPARATOR).next() { - if last == "csh" || last == "tcsh" { + let shell_path: &Path = s.as_ref(); + if let Some(name) = shell_path.file_name() { + if name == "csh" || name == "tcsh" { OutputFmt::CShell } else { OutputFmt::Shell