Skip to content
Myr

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

2 files+13 added−12 removed

modified:src/main.rs+6 added-10 removed
52 unmodified lines
53 /// Whether to follow symlinks or not.54 follow_links: bool,5556 /// Whether elements of output should be separated by a null character57 zero: bool,57 null_separator: bool,5859 /// 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 includes
83 unmodified lines
145 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 output156157 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" };159160 let r = write!(&mut std::io::stdout(), "{}{}{}", prefix, path_str, separator);161162 if r.is_err() {
74 unmodified lines
237 .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 lines
317 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::Absolute
19 unmodified lines
modified:tests/test.sh+7 added-2 removed
30 unmodified lines
31 tmp_output="$(mktemp -t "$MKTEMP_TEMPLATE")"3233 echo "$expected_output" > "$tmp_expected"3435 "$fd" "$@" | xargs -0 echo -n | sort -f > "$tmp_output"35 "$fd" "$@" | sed -e 's/\x0/NULL\n/g' | sort -f > "$tmp_output"3637 echo -ne " ${bold}▶${reset} Testing 'fd $*' ... "3839 if diff -q "$tmp_expected" "$tmp_output" > /dev/null; then
141 unmodified lines
181symlink/c.foo182symlink/C.Foo2" --follow c.foo183184suite "Null separator (--print0)"185expect "one/two/C.Foo2 one/two/c.foo one/two/three/d.foo one/two/three/directory_foo one/b.foo a.foo" --print0 foo185expect "a.fooNULL186one/b.fooNULL187one/two/C.Foo2NULL188one/two/c.fooNULL189one/two/three/d.fooNULL190one/two/three/directory_fooNULL" --print0 foo191192193suite "Maximum depth (--max-depth)"194expect "a.foo
41 unmodified lines