summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2023-12-06 07:49:27 +0100
committerSebastian Thiel <sebastian.thiel@icloud.com>2023-12-06 07:49:27 +0100
commit74e6d4222a7f70253f1d69eb8e7cf94114827852 (patch)
tree9d033463be4cb74b51c55fae965d8eb1a87dfcce
parente9fb2fda3478fefa38bdb9d176380bae5545dbc6 (diff)
assure `device_id` is taken from the final CWD (#186) (#110)
-rw-r--r--src/main.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index ca16302..a655ea1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -49,7 +49,7 @@ fn main() -> Result<()> {
let res = TerminalApp::initialize(
&mut terminal,
walk_options,
- paths_from(input, !opt.stay_on_filesystem)?,
+ extract_paths_maybe_set_cwd(input, !opt.stay_on_filesystem)?,
Interaction::Full,
)?
.map(|(keys_rx, mut app)| {
@@ -101,7 +101,7 @@ fn main() -> Result<()> {
walk_options,
!no_total,
!no_sort,
- paths_from(input, !opt.stay_on_filesystem)?,
+ extract_paths_maybe_set_cwd(input, !opt.stay_on_filesystem)?,
)?;
if statistics {
writeln!(io::stderr(), "{:?}", stats).ok();
@@ -117,7 +117,7 @@ fn main() -> Result<()> {
walk_options,
true,
true,
- paths_from(opt.input, !opt.stay_on_filesystem)?,
+ extract_paths_maybe_set_cwd(opt.input, !opt.stay_on_filesystem)?,
)?
.0
}
@@ -126,15 +126,17 @@ fn main() -> Result<()> {
process::exit(res.to_exit_code());
}
-fn paths_from(mut paths: Vec<PathBuf>, cross_filesystems: bool) -> Result<Vec<PathBuf>, io::Error> {
- let device_id = std::env::current_dir()
- .ok()
- .and_then(|cwd| crossdev::init(&cwd).ok());
-
+fn extract_paths_maybe_set_cwd(
+ mut paths: Vec<PathBuf>,
+ cross_filesystems: bool,
+) -> Result<Vec<PathBuf>, io::Error> {
if paths.len() == 1 {
std::env::set_current_dir(&paths[0])?;
- paths.remove(0);
+ paths.clear();
}
+ let device_id = std::env::current_dir()
+ .ok()
+ .and_then(|cwd| crossdev::init(&cwd).ok());
if paths.is_empty() {
cwd_dirlist().map(|paths| match device_id {