From 73e844dbfe4d1c169a0f87249684144655be20a2 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 18 Jan 2019 13:40:05 +0100 Subject: [PATCH] bin/proxmox-backup-client.rs: improve file name completion --- src/bin/proxmox-backup-client.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index aa617ad3..1ad3a1c0 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -130,9 +130,12 @@ pub fn complete_file_name(arg: &str) -> Vec { let mut dirname = std::path::PathBuf::from(arg); - if let Ok(stat) = nix::sys::stat::fstatat(libc::AT_FDCWD, &dirname, AtFlags::empty()) { + let is_dir = match nix::sys::stat::fstatat(libc::AT_FDCWD, &dirname, AtFlags::empty()) { + Ok(stat) => (stat.st_mode & libc::S_IFMT) == libc::S_IFDIR, + Err(_) => false, + }; - } else { + if !is_dir { if let Some(parent) = dirname.parent() { dirname = parent.to_owned(); }