main.rs
This file
Path
src/main.rs
399 lines · 13.6 KiB · Rust
Last changed by
Add new `--type socket` and `--type pipe` filterssharkdpbefore adoptioncb56add
History of this fileTake it
The walk stopped after 200 commits: lines older than 45d1b15 point at it.
Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 1why, one step back1mod app;Clean up include ordersharkdpbefore adoption53557ef
line 2why, one step back2mod error;Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 3–4why, one step back3mod exec;4mod exit_codes;Rename fshelper to filesystemsharkdpbefore adoptionb415d72
line 5why, one step back5mod filesystem;Move filetypes up from 'internal'sharkdpbefore adoption5c27ab1
line 6why, one step back6mod filetypes;Move filter up from internalsharkdpbefore adoption9f738ad
line 7why, one step back7mod filter;Move FdOptions to Optionssharkdpbefore adoption65096a6
line 8why, one step back8mod options;Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 9why, one step back9mod output;Move regex helpers to new modulesharkdpbefore adoption809fd8f
line 10why, one step back10mod regex_helper;Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 11–14why, one step back11mod walk;1213use std::env;14use std::path::{Path, PathBuf};Expose exit status from `--exec-batch <cmd>`sharkdpbefore adoptiona0505bd
line 15why, one step back15use std::process;Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 16–18why, one step back16use std::sync::Arc;17use std::time;18Proper error handling in main.rssharkdpbefore adoptionbce9527
line 19why, one step back19use anyhow::{anyhow, Context, Result};Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 20why, one step back20use atty::Stream;--glob: '*' does not match on path separatorssharkdpbefore adoption47974b6
line 21why, one step back21use globset::GlobBuilder;Use lscolors cratesharkdpbefore adoption4b5efa3
line 22why, one step back22use lscolors::LsColors;Use regex::bytes::* instead of regex::*sharkdpbefore adoption641594c
line 23why, one step back23use regex::bytes::{RegexBuilder, RegexSetBuilder};Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 24why, one step back24[2018 edition] run cargo fix edition and edition-idiomsAlexandru Macoveibefore adoption64e6ea9
line 25why, one step back25use crate::exec::CommandTemplate;Proper error handling in main.rssharkdpbefore adoptionbce9527
line 26why, one step back26use crate::exit_codes::ExitCode;Move filetypes up from 'internal'sharkdpbefore adoption5c27ab1
line 27why, one step back27use crate::filetypes::FileTypes;Move filter up from internalsharkdpbefore adoption9f738ad
line 28why, one step back28use crate::filter::{SizeFilter, TimeFilter};Move FdOptions to Optionssharkdpbefore adoption65096a6
line 29why, one step back29use crate::options::Options;Move regex helpers to new modulesharkdpbefore adoption809fd8f
line 30why, one step back30use crate::regex_helper::pattern_has_uppercase_char;Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 31why, one step back31Disable jemallocator on Windowssharkdpbefore adoption4e20803
line 32why, one step back32// We use jemalloc for performance reasons, see https://github.com/sharkdp/fd/pull/481Clean up cfg linesharkdpbefore adoption9350c85
line 33why, one step back33#[cfg(all(not(windows), not(target_env = "musl")))]Use jemallocsharkdpbefore adoption5a15486
lines 34–36why, one step back34#[global_allocator]35static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;36Proper error handling in main.rssharkdpbefore adoptionbce9527
line 37why, one step back37fn run() -> Result<ExitCode> {Remove possibility to use '--exec <cmd>' with a single dashsharkdpbefore adoption342d12d
line 38why, one step back38 let matches = app::build_app().get_matches_from(env::args_os());Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 39why, one step back39Allow changing current working directory of fdRafał Hajdackibefore adoptionfb205f5
line 40why, one step back40 // Set the current working directory of the processReimplement dirname, basename, remove_extension for OsStrsharkdpbefore adoption7e3c69c
line 41why, one step back41 if let Some(base_directory) = matches.value_of_os("base-directory") {Refactor directory handlingsharkdpbefore adoption094516a
lines 42–43why, one step back42 let base_directory = Path::new(base_directory);43 if !filesystem::is_dir(base_directory) {Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 44–45why, one step back44 return Err(anyhow!(45 "The '--base-directory' path '{}' is not a directory.",Refactor directory handlingsharkdpbefore adoption094516a
line 46why, one step back46 base_directory.to_string_lossy()Proper error handling in main.rssharkdpbefore adoptionbce9527
line 47why, one step back47 ));Allow changing current working directory of fdRafał Hajdackibefore adoptionfb205f5
line 48why, one step back48 }Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 49–54why, one step back49 env::set_current_dir(base_directory).with_context(|| {50 format!(51 "Could not set '{}' as the current working directory.",52 base_directory.to_string_lossy()53 )54 })?;Allow changing current working directory of fdRafał Hajdackibefore adoptionfb205f5
lines 55–56why, one step back55 }56Refactor directory handlingsharkdpbefore adoption094516a
lines 57–58why, one step back57 let current_directory = Path::new(".");58 if !filesystem::is_dir(current_directory) {Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 59–61why, one step back59 return Err(anyhow!(60 "Could not retrieve current directory (has it been deleted?)."61 ));Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 62–63why, one step back62 }63Refactor directory handlingsharkdpbefore adoption094516a
line 64why, one step back64 // Get the search patternReimplement dirname, basename, remove_extension for OsStrsharkdpbefore adoption7e3c69c
lines 65–73why, one step back65 let pattern = matches66 .value_of_os("pattern")67 .map(|p| {68 p.to_str().ok_or(anyhow!(69 "The search pattern includes invalid UTF-8 sequences."70 ))71 })72 .transpose()?73 .unwrap_or("");Refactor directory handlingsharkdpbefore adoption094516a
line 74why, one step back74Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 75–76why, one step back75 // Get one or more root directories to search.76 let mut dir_vec: Vec<_> = match matchesReimplement dirname, basename, remove_extension for OsStrsharkdpbefore adoption7e3c69c
lines 77–78why, one step back77 .values_of_os("path")78 .or_else(|| matches.values_of_os("search-path"))Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 79–82why, one step back79 {80 Some(paths) => paths81 .map(|path| {82 let path_buffer = PathBuf::from(path);Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 83–87why, one step back83 if filesystem::is_dir(&path_buffer) {84 Ok(path_buffer)85 } else {86 Err(anyhow!(87 "Search path '{}' is not a directory.",Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 88why, one step back88 path_buffer.to_string_lossy()Proper error handling in main.rssharkdpbefore adoptionbce9527
line 89why, one step back89 ))Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 90–91why, one step back90 }91 })Proper error handling in main.rssharkdpbefore adoptionbce9527
line 92why, one step back92 .collect::<Result<Vec<_>>>()?,Refactor directory handlingsharkdpbefore adoption094516a
line 93why, one step back93 None => vec![current_directory.to_path_buf()],Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 94–101why, one step back94 };9596 if matches.is_present("absolute-path") {97 dir_vec = dir_vec98 .iter()99 .map(|path_buffer| {100 path_buffer101 .canonicalize()Rename fshelper to filesystemsharkdpbefore adoptionb415d72
line 102why, one step back102 .and_then(|pb| filesystem::absolute_path(pb.as_path()))Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 103–110why, one step back103 .unwrap()104 })105 .collect();106 }107108 // Detect if the user accidentally supplied a path instead of a search pattern109 if !matches.is_present("full-path")110 && pattern.contains(std::path::MAIN_SEPARATOR)Rename fshelper to filesystemsharkdpbefore adoptionb415d72
line 111why, one step back111 && filesystem::is_dir(Path::new(pattern))Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 112why, one step back112 {Proper error handling in main.rssharkdpbefore adoptionbce9527
line 113why, one step back113 return Err(anyhow!(Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 114–117why, one step back114 "The search pattern '{pattern}' contains a path-separation character ('{sep}') \115 and will not lead to any search results.\n\n\116 If you want to search for all files inside the '{pattern}' directory, use a match-all pattern:\n\n \117 fd . '{pattern}'\n\n\Proper error handling in main.rssharkdpbefore adoptionbce9527
line 118why, one step back118 Instead, if you want your pattern to match the full file path, use:\n\n \Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 119–121why, one step back119 fd --full-path '{pattern}'",120 pattern = pattern,121 sep = std::path::MAIN_SEPARATOR,Proper error handling in main.rssharkdpbefore adoptionbce9527
line 122why, one step back122 ));Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 123–124why, one step back123 }124Implement glob-based searchessharkdpbefore adoptiond5da615
line 125why, one step back125 let pattern_regex = if matches.is_present("glob") {--glob: '*' does not match on path separatorssharkdpbefore adoption47974b6
line 126why, one step back126 let glob = GlobBuilder::new(pattern).literal_separator(true).build()?;Implement glob-based searchessharkdpbefore adoptiond5da615
lines 127–129why, one step back127 glob.regex().to_owned()128 } else if matches.is_present("fixed-strings") {129 // Treat pattern as literal string if '--fixed-strings' is usedAdd support for batch execution of commandkimsnjbefore adoption45d1b15
lines 130–139why, one step back130 regex::escape(pattern)131 } else {132 String::from(pattern)133 };134135 // The search will be case-sensitive if the command line flag is set or136 // if the pattern has an uppercase character (smart case).137 let case_sensitive = !matches.is_present("ignore-case")138 && (matches.is_present("case-sensitive") || pattern_has_uppercase_char(&pattern_regex));139Print path as raw bytes, allowing invalid UTF-8 filenames to be passed to other processessharkdpbefore adoption6c9e743
line 140why, one step back140 let interactive_terminal = atty::is(Stream::Stdout);Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 141–143why, one step back141 let colored_output = match matches.value_of("color") {142 Some("always") => true,143 Some("never") => false,Print path as raw bytes, allowing invalid UTF-8 filenames to be passed to other processessharkdpbefore adoption6c9e743
line 144why, one step back144 _ => env::var_os("NO_COLOR").is_none() && interactive_terminal,Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 145–146why, one step back145 };146Remove type annotation.Nathan Moreaubefore adoption588e344
line 147why, one step back147 let path_separator = matches.value_of("path-separator").map(|str| str.to_owned());Add path-separator option.Nathan Moreaubefore adoption24e108e
line 148why, one step back148Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 149why, one step back149 #[cfg(windows)]Always enable colors on Windows, closes #469sharkdpbefore adoption3b42898
line 150why, one step back150 ansi_term::enable_ansi_support().ok();Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 151–152why, one step back151152 let ls_colors = if colored_output {Use lscolors cratesharkdpbefore adoption4b5efa3
line 153why, one step back153 Some(LsColors::from_env().unwrap_or_default())Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 154–157why, one step back154 } else {155 None156 };157Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 158–164why, one step back158 let command = if let Some(args) = matches.values_of("exec") {159 Some(CommandTemplate::new(args))160 } else if let Some(args) = matches.values_of("exec-batch") {161 Some(CommandTemplate::new_batch(args)?)162 } else if matches.is_present("list-details") {163 let color = matches.value_of("color").unwrap_or("auto");164 let color_arg = ["--color=", color].concat();Add `-l`/`--list` optionsharkdpbefore adoptionda5cd12
line 165why, one step back165Add testsharkdpbefore adoption4287cdd
line 166why, one step back166 #[allow(unused)]Windows support (if GNU ls is installed)sharkdpbefore adoption0b7febc
lines 167–176why, one step back167 let gnu_ls = |command_name| {168 vec![169 command_name,170 "-l", // long listing format171 "--human-readable", // human readable file sizes172 "--directory", // list directories themselves, not their contents173 &color_arg,174 ]175 };176Add MacOS support for -l/--list-detailssharkdpbefore adoption2685728
lines 177–179why, one step back177 let cmd: Vec<&str> = if cfg!(unix) {178 if !cfg!(target_os = "macos") {179 // Non-MacOS UnixWindows support (if GNU ls is installed)sharkdpbefore adoption0b7febc
line 180why, one step back180 gnu_ls("ls")Add MacOS support for -l/--list-detailssharkdpbefore adoption2685728
lines 181–182why, one step back181 } else {182 // MacOSDo not show output of 'gls --version'sharkdpbefore adoption0f5500a
line 183why, one step back183 use std::process::{Command, Stdio};Add MacOS support for -l/--list-detailssharkdpbefore adoption2685728
line 184why, one step back184Add comment why we prefer glssharkdpbefore adoptiond91100e
line 185why, one step back185 // Use GNU ls, if available (support for --color=auto, better LS_COLORS support)Do not show output of 'gls --version'sharkdpbefore adoption0f5500a
lines 186–191why, one step back186 let gnu_ls_exists = Command::new("gls")187 .arg("--version")188 .stdout(Stdio::null())189 .stderr(Stdio::null())190 .status()191 .is_ok();Add MacOS support for -l/--list-detailssharkdpbefore adoption2685728
lines 192–193why, one step back192193 if gnu_ls_exists {Windows support (if GNU ls is installed)sharkdpbefore adoption0b7febc
line 194why, one step back194 gnu_ls("gls")Add MacOS support for -l/--list-detailssharkdpbefore adoption2685728
lines 195–209why, one step back195 } else {196 let mut cmd = vec![197 "ls", // MacOS version of ls198 "-l", // long listing format199 "-h", // '--human-readable' is not available on MacOS, '-h' is200 "-d", // '--directory' is not available, but '-d' is201 ];202203 if colored_output {204 cmd.push("-G");205 }206207 cmd208 }209 }Windows support (if GNU ls is installed)sharkdpbefore adoption0b7febc
lines 210–224why, one step back210 } else if cfg!(windows) {211 use std::process::{Command, Stdio};212213 // Use GNU ls, if available214 let gnu_ls_exists = Command::new("ls")215 .arg("--version")216 .stdout(Stdio::null())217 .stderr(Stdio::null())218 .status()219 .is_ok();220221 if gnu_ls_exists {222 gnu_ls("ls")223 } else {224 return Err(anyhow!(Add testsharkdpbefore adoption4287cdd
line 225why, one step back225 "'fd --list-details' is not supported on Windows unless GNU 'ls' is installed."Windows support (if GNU ls is installed)sharkdpbefore adoption0b7febc
lines 226–227why, one step back226 ));227 }Add MacOS support for -l/--list-detailssharkdpbefore adoption2685728
lines 228–229why, one step back228 } else {229 return Err(anyhow!(Add testsharkdpbefore adoption4287cdd
line 230why, one step back230 "'fd --list-details' is not supported on this platform."Add MacOS support for -l/--list-detailssharkdpbefore adoption2685728
lines 231–234why, one step back231 ));232 };233234 Some(CommandTemplate::new_batch(&cmd).unwrap())Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 235–237why, one step back235 } else {236 None237 };Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 238why, one step back238Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 239–244why, one step back239 let size_limits = if let Some(vs) = matches.values_of("size") {240 vs.map(|sf| {241 SizeFilter::from_string(sf).ok_or(anyhow!(242 "'{}' is not a valid size constraint. See 'fd --help'.",243 sf244 ))Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 245why, one step back245 })Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 246–249why, one step back246 .collect::<Result<Vec<_>>>()?247 } else {248 vec![]249 };Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 250–256why, one step back250251 let now = time::SystemTime::now();252 let mut time_constraints: Vec<TimeFilter> = Vec::new();253 if let Some(t) = matches.value_of("changed-within") {254 if let Some(f) = TimeFilter::after(&now, t) {255 time_constraints.push(f);256 } else {Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 257–260why, one step back257 return Err(anyhow!(258 "'{}' is not a valid date or duration. See 'fd --help'.",259 t260 ));Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 261–266why, one step back261 }262 }263 if let Some(t) = matches.value_of("changed-before") {264 if let Some(f) = TimeFilter::before(&now, t) {265 time_constraints.push(f);266 } else {Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 267–270why, one step back267 return Err(anyhow!(268 "'{}' is not a valid date or duration. See 'fd --help'.",269 t270 ));Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 271–273why, one step back271 }272 }273Move FdOptions to Optionssharkdpbefore adoption65096a6
line 274why, one step back274 let config = Options {Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 275–284why, one step back275 case_sensitive,276 search_full_path: matches.is_present("full-path"),277 ignore_hidden: !(matches.is_present("hidden")278 || matches.occurrences_of("rg-alias-hidden-ignore") >= 2),279 read_fdignore: !(matches.is_present("no-ignore")280 || matches.is_present("rg-alias-hidden-ignore")),281 read_vcsignore: !(matches.is_present("no-ignore")282 || matches.is_present("rg-alias-hidden-ignore")283 || matches.is_present("no-ignore-vcs")),284 follow_links: matches.is_present("follow"),Rename `--same-file-system` to `--one-file-system`Simon Engmannbefore adoption94993ca
line 285why, one step back285 one_file_system: matches.is_present("one-file-system"),Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 286–287why, one step back286 null_separator: matches.is_present("null_separator"),287 max_depth: matchesAdd --min-depth and --exact-depthsharkdpbefore adoptiond63c63b
line 288why, one step back288 .value_of("max-depth")Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 289why, one step back289 .or_else(|| matches.value_of("rg-depth"))Add --min-depth and --exact-depthsharkdpbefore adoptiond63c63b
lines 290–294why, one step back290 .or_else(|| matches.value_of("exact-depth"))291 .and_then(|n| usize::from_str_radix(n, 10).ok()),292 min_depth: matches293 .value_of("min-depth")294 .or_else(|| matches.value_of("exact-depth"))Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 295–307why, one step back295 .and_then(|n| usize::from_str_radix(n, 10).ok()),296 threads: std::cmp::max(297 matches298 .value_of("threads")299 .and_then(|n| usize::from_str_radix(n, 10).ok())300 .unwrap_or_else(num_cpus::get),301 1,302 ),303 max_buffer_time: matches304 .value_of("max-buffer-time")305 .and_then(|n| u64::from_str_radix(n, 10).ok())306 .map(time::Duration::from_millis),307 ls_colors,Print path as raw bytes, allowing invalid UTF-8 filenames to be passed to other processessharkdpbefore adoption6c9e743
line 308why, one step back308 interactive_terminal,Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 309–319why, one step back309 file_types: matches.values_of("file-type").map(|values| {310 let mut file_types = FileTypes::default();311 for value in values {312 match value {313 "f" | "file" => file_types.files = true,314 "d" | "directory" => file_types.directories = true,315 "l" | "symlink" => file_types.symlinks = true,316 "x" | "executable" => {317 file_types.executables_only = true;318 file_types.files = true;319 }Add new `--type socket` and `--type pipe` filterssharkdpbefore adoptioncb56add
lines 320–322why, one step back320 "e" | "empty" => file_types.empty_only = true,321 "s" | "socket" => file_types.sockets = true,322 "p" | "pipe" => file_types.pipes = true,Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 323–334why, one step back323 _ => unreachable!(),324 }325 }326327 // If only 'empty' was specified, search for both files and directories:328 if file_types.empty_only && !(file_types.files || file_types.directories) {329 file_types.files = true;330 file_types.directories = true;331 }332333 file_types334 }),Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 335–345why, one step back335 extensions: matches336 .values_of("extension")337 .map(|exts| {338 let patterns = exts339 .map(|e| e.trim_start_matches('.'))340 .map(|e| format!(r".\.{}$", regex::escape(e)));341 RegexSetBuilder::new(patterns)342 .case_insensitive(true)343 .build()344 })345 .transpose()?,avoid cloning command, in the wake of 9d26b74Alexandru Macoveibefore adoptionc2b46f2
line 346why, one step back346 command: command.map(Arc::new),Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 347–357why, one step back347 exclude_patterns: matches348 .values_of("exclude")349 .map(|v| v.map(|p| String::from("!") + p).collect())350 .unwrap_or_else(|| vec![]),351 ignore_files: matches352 .values_of("ignore-file")353 .map(|vs| vs.map(PathBuf::from).collect())354 .unwrap_or_else(|| vec![]),355 size_constraints: size_limits,356 time_constraints,357 show_filesystem_errors: matches.is_present("show-errors"),Add path-separator option.Nathan Moreaubefore adoption24e108e
line 358why, one step back358 path_separator,Add --max-results=<count> optionsharkdpbefore adoptiond43827f
lines 359–361why, one step back359 max_results: matches360 .value_of("max-results")361 .and_then(|n| usize::from_str_radix(n, 10).ok())Add alias -1 for --max-results=1Danny Möschbefore adoption2bab4a2
line 362why, one step back362 .filter(|&n| n != 0)--glob: '*' does not match on path separatorssharkdpbefore adoption47974b6
lines 363–369why, one step back363 .or_else(|| {364 if matches.is_present("max-one-result") {365 Some(1)366 } else {367 None368 }369 }),Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 370–371why, one step back370 };371Proper error handling in main.rssharkdpbefore adoptionbce9527
line 372why, one step back372 let re = RegexBuilder::new(&pattern_regex)Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 373–375why, one step back373 .case_insensitive(!config.case_sensitive)374 .dot_matches_new_line(true)375 .build()Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 376–384why, one step back376 .map_err(|e| {377 anyhow!(378 "{}\n\nNote: You can use the '--fixed-strings' option to search for a \379 literal string instead of a regular expression. Alternatively, you can \380 also use the '--glob' option to match on a glob pattern.",381 e.to_string()382 )383 })?;384Proper error handling within walk.rssharkdpbefore adoption4590ae8
line 385why, one step back385 walk::scan(&dir_vec, Arc::new(re), Arc::new(config))Proper error handling in main.rssharkdpbefore adoptionbce9527
lines 386–391why, one step back386}387388fn main() {389 let result = run();390 match result {391 Ok(exit_code) => {Expose exit status from `--exec-batch <cmd>`sharkdpbefore adoptiona0505bd
lines 392–393why, one step back392 process::exit(exit_code.into());393 }Add support for batch execution of commandkimsnjbefore adoption45d1b15
line 394why, one step back394 Err(err) => {Proper error handling in main.rssharkdpbefore adoptionbce9527
line 395why, one step back395 eprintln!("[fd error]: {}", err);Remove process::exit instancesharkdpbefore adoption4815ee4
line 396why, one step back396 process::exit(ExitCode::GeneralError.into());Add support for batch execution of commandkimsnjbefore adoption45d1b15
lines 397–399why, one step back397 }398 }399}