Rename config parameter for print0 and fix sorting in tests
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by sharkdp · parent 10ea476 · Browse files · 2 files·+13 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+13 added−12 removed
- tests:+7 added−2 removed
- other:+6 added−10 removed
Provenance
- Commit
2d1d24c- Tree
32d04c0- Author
sharkdp <davidpeter@web.de>- Committer
sharkdp <davidpeter@web.de>- Parent
10ea476
2 files changed+13 added−12 removed
modified:src/main.rs+6 added-10 removed
52 unmodified lines53 /// Whether to follow symlinks or not.54 follow_links: bool,55 56 /// Whether elements of output should be separated by a null character57- zero: bool,57+ null_separator: bool,58 59 /// The maximum search depth, or `None` if no maximum search depth should be set.60 ///61 /// A depth of `1` includes all files under the current directory, a depth of `2` also includes83 unmodified lines145 let sep = std::path::MAIN_SEPARATOR.to_string();146 print!("{}", style.paint(sep));147 }148 }149- if config.zero {149+ if config.null_separator {150 print!("{}", '\0');151 } else {152 println!();153 }154 } else {155 // Uncolorized output156 157 let prefix = if config.path_display == PathDisplay::Absolute { ROOT_DIR } else { "" };158- let separator = if config.zero {159- "\0"160- } else {161- "\n"162- };158+ let separator = if config.null_separator { "\0" } else { "\n" };159 160 let r = write!(&mut std::io::stdout(), "{}{}{}", prefix, path_str, separator);161 162 if r.is_err() {74 unmodified lines237 .arg(Arg::with_name("follow")238 .long("follow")239 .short("f")240 .help("Follow symlinks"))245- .arg(Arg::with_name("zero")241+ .arg(Arg::with_name("null_separator")242 .long("print0")243 .short("0")248- .help("Separate each path by the null character"))244+ .help("Separate results by the null character"))245 .arg(Arg::with_name("absolute-path")246 .long("absolute-path")247 .short("a")248 .help("Show absolute instead of relative paths"))68 unmodified lines317 search_full_path: matches.is_present("full-path"),318 ignore_hidden: !matches.is_present("hidden"),319 read_ignore: !matches.is_present("no-ignore"),320 follow_links: matches.is_present("follow"),325- zero: matches.is_present("zero"),321+ null_separator: matches.is_present("null_separator"),322 max_depth: matches.value_of("depth")323 .and_then(|ds| usize::from_str_radix(ds, 10).ok()),324 path_display: if matches.is_present("absolute-path") || root_dir_is_absolute {325 PathDisplay::Absolute19 unmodified linesmodified:tests/test.sh+7 added-2 removed
30 unmodified lines31 tmp_output="$(mktemp -t "$MKTEMP_TEMPLATE")"32 33 echo "$expected_output" > "$tmp_expected"34 35- "$fd" "$@" | xargs -0 echo -n | sort -f > "$tmp_output"35+ "$fd" "$@" | sed -e 's/\x0/NULL\n/g' | sort -f > "$tmp_output"36 37 echo -ne " ${bold}▶${reset} Testing 'fd $*' ... "38 39 if diff -q "$tmp_expected" "$tmp_output" > /dev/null; then141 unmodified lines181 symlink/c.foo182 symlink/C.Foo2" --follow c.foo183 184 suite "Null separator (--print0)"185-expect "one/two/C.Foo2 one/two/c.foo one/two/three/d.foo one/two/three/directory_foo one/b.foo a.foo" --print0 foo185+expect "a.fooNULL186+one/b.fooNULL187+one/two/C.Foo2NULL188+one/two/c.fooNULL189+one/two/three/d.fooNULL190+one/two/three/directory_fooNULL" --print0 foo191 192 193 suite "Maximum depth (--max-depth)"194 expect "a.foo41 unmodified lines