1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

dircolors: extract shell name from $SHELL properly

This commit is contained in:
Knight 2016-06-17 21:54:44 +08:00
parent 2758455d73
commit 5dba86dfa2

View file

@ -36,11 +36,12 @@ pub enum OutputFmt {
} }
pub fn guess_syntax() -> OutputFmt { pub fn guess_syntax() -> OutputFmt {
use std::path; use std::path::Path;
match env::var("SHELL") { match env::var("SHELL") {
Ok(ref s) if !s.is_empty() => { Ok(ref s) if !s.is_empty() => {
if let Some(last) = s.rsplit(path::MAIN_SEPARATOR).next() { let shell_path: &Path = s.as_ref();
if last == "csh" || last == "tcsh" { if let Some(name) = shell_path.file_name() {
if name == "csh" || name == "tcsh" {
OutputFmt::CShell OutputFmt::CShell
} else { } else {
OutputFmt::Shell OutputFmt::Shell