1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37: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 {
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