├── src ├── uu │ ├── cut │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ └── src │ │ │ └── searcher.rs │ ├── printf │ │ ├── src │ │ │ ├── mod.rs │ │ │ ├── tokenize │ │ │ │ ├── num_format │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── formatters │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── floatf.rs │ │ │ │ │ │ ├── scif.rs │ │ │ │ │ │ └── base_conv │ │ │ │ │ │ │ └── tests.rs │ │ │ │ │ └── format_field.rs │ │ │ │ ├── mod.rs │ │ │ │ └── token.rs │ │ │ └── cli.rs │ │ └── Cargo.toml │ ├── stdbuf │ │ ├── src │ │ │ └── libstdbuf │ │ │ │ ├── build.rs │ │ │ │ ├── Cargo.toml │ │ │ │ └── src │ │ │ │ └── libstdbuf.rs │ │ ├── Cargo.toml │ │ └── build.rs │ ├── split │ │ ├── README.md │ │ └── Cargo.toml │ ├── cksum │ │ ├── Cargo.toml │ │ └── build.rs │ ├── factor │ │ └── Cargo.toml │ ├── echo │ │ └── Cargo.toml │ ├── fold │ │ └── Cargo.toml │ ├── true │ │ ├── Cargo.toml │ │ └── src │ │ │ └── true.rs │ ├── false │ │ ├── Cargo.toml │ │ └── src │ │ │ └── false.rs │ ├── du │ │ └── Cargo.toml │ ├── ln │ │ └── Cargo.toml │ ├── mv │ │ └── Cargo.toml │ ├── wc │ │ └── Cargo.toml │ ├── basename │ │ └── Cargo.toml │ ├── head │ │ └── Cargo.toml │ ├── join │ │ └── Cargo.toml │ ├── link │ │ ├── Cargo.toml │ │ └── src │ │ │ └── link.rs │ ├── pwd │ │ └── Cargo.toml │ ├── seq │ │ └── Cargo.toml │ ├── sum │ │ └── Cargo.toml │ ├── tac │ │ └── Cargo.toml │ ├── uniq │ │ └── Cargo.toml │ ├── arch │ │ ├── Cargo.toml │ │ └── src │ │ │ └── arch.rs │ ├── hostid │ │ ├── Cargo.toml │ │ └── src │ │ │ └── hostid.rs │ ├── paste │ │ └── Cargo.toml │ ├── rmdir │ │ └── Cargo.toml │ ├── tsort │ │ └── Cargo.toml │ ├── dirname │ │ ├── Cargo.toml │ │ └── src │ │ │ └── dirname.rs │ ├── logname │ │ ├── Cargo.toml │ │ └── src │ │ │ └── logname.rs │ ├── numfmt │ │ └── Cargo.toml │ ├── date │ │ └── Cargo.toml │ ├── expr │ │ └── Cargo.toml │ ├── id │ │ └── Cargo.toml │ ├── shuf │ │ └── Cargo.toml │ ├── tee │ │ └── Cargo.toml │ ├── comm │ │ └── Cargo.toml │ ├── dircolors │ │ └── Cargo.toml │ ├── fmt │ │ └── Cargo.toml │ ├── groups │ │ ├── Cargo.toml │ │ └── src │ │ │ └── groups.rs │ ├── nice │ │ └── Cargo.toml │ ├── printenv │ │ └── Cargo.toml │ ├── truncate │ │ └── Cargo.toml │ ├── base64 │ │ ├── Cargo.toml │ │ └── src │ │ │ └── base64.rs │ ├── mkdir │ │ └── Cargo.toml │ ├── mknod │ │ ├── Cargo.toml │ │ └── src │ │ │ └── parsemode.rs │ ├── pinky │ │ └── Cargo.toml │ ├── mkfifo │ │ └── Cargo.toml │ ├── tr │ │ └── Cargo.toml │ ├── uname │ │ └── Cargo.toml │ ├── unlink │ │ └── Cargo.toml │ ├── expand │ │ └── Cargo.toml │ ├── kill │ │ └── Cargo.toml │ ├── pathchk │ │ └── Cargo.toml │ ├── rm │ │ └── Cargo.toml │ ├── users │ │ └── Cargo.toml │ ├── chgrp │ │ └── Cargo.toml │ ├── chroot │ │ └── Cargo.toml │ ├── nproc │ │ └── Cargo.toml │ ├── relpath │ │ └── Cargo.toml │ ├── sleep │ │ └── Cargo.toml │ ├── tty │ │ └── Cargo.toml │ ├── unexpand │ │ └── Cargo.toml │ ├── mktemp │ │ ├── Cargo.toml │ │ └── src │ │ │ └── tempdir.rs │ ├── realpath │ │ └── Cargo.toml │ ├── chmod │ │ └── Cargo.toml │ ├── nohup │ │ └── Cargo.toml │ ├── od │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── formatteriteminfo.rs │ │ │ └── byteorder_io.rs │ ├── stat │ │ └── Cargo.toml │ ├── uptime │ │ └── Cargo.toml │ ├── readlink │ │ └── Cargo.toml │ ├── who │ │ └── Cargo.toml │ ├── sort │ │ └── Cargo.toml │ ├── test │ │ └── Cargo.toml │ ├── shred │ │ └── Cargo.toml │ ├── touch │ │ └── Cargo.toml │ ├── base32 │ │ ├── Cargo.toml │ │ └── src │ │ │ └── base32.rs │ ├── cat │ │ └── Cargo.toml │ ├── timeout │ │ └── Cargo.toml │ ├── hostname │ │ └── Cargo.toml │ ├── nl │ │ └── Cargo.toml │ ├── install │ │ ├── Cargo.toml │ │ └── src │ │ │ └── mode.rs │ ├── ptx │ │ └── Cargo.toml │ ├── chown │ │ └── Cargo.toml │ ├── env │ │ └── Cargo.toml │ ├── sync │ │ └── Cargo.toml │ ├── tail │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── platform │ │ │ │ ├── redox.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── unix.rs │ │ │ │ └── windows.rs │ │ └── README.md │ ├── whoami │ │ ├── src │ │ │ ├── platform │ │ │ │ ├── mod.rs │ │ │ │ ├── unix.rs │ │ │ │ └── windows.rs │ │ │ └── whoami.rs │ │ └── Cargo.toml │ ├── yes │ │ └── Cargo.toml │ ├── hashsum │ │ └── Cargo.toml │ ├── more │ │ └── Cargo.toml │ ├── ls │ │ └── Cargo.toml │ └── cp │ │ ├── Cargo.toml │ │ └── README.md └── common │ ├── uumain.rs │ └── mkmain.rs ├── tests ├── fixtures │ ├── comm │ │ ├── empty │ │ ├── a │ │ ├── b │ │ ├── emptyempty.expected │ │ ├── ab1.expected │ │ ├── ab2.expected │ │ ├── ab3.expected │ │ ├── aempty.expected │ │ ├── lowercase_uppercase │ │ ├── ab.expected │ │ ├── bad_order_1 │ │ ├── bad_order_2 │ │ ├── lowercase_uppercase.c.expected │ │ ├── bad_order12.check_order.expected │ │ ├── lowercase_uppercase.en_us.expected │ │ ├── ab_delimiter_word.expected │ │ ├── defaultcheck_unintuitive_2 │ │ ├── defaultcheck_unintuitive_1 │ │ ├── bad_order11.defaultcheck_order.expected │ │ ├── bad_order12.nocheck_order.expected │ │ └── defaultcheck_unintuitive.expected │ ├── od │ │ ├── 0 │ │ ├── c │ │ ├── x │ │ └── -f │ ├── join │ │ ├── empty.txt │ │ ├── fields_1.txt │ │ ├── capitalized.txt │ │ ├── suppress_joined.expected │ │ ├── semicolon_fields_2.txt │ │ ├── default.expected │ │ ├── empty_key.expected │ │ ├── case_insensitive.expected │ │ ├── semicolon_separated.expected │ │ ├── different_lengths.txt │ │ ├── fields_3.txt │ │ ├── header_1.txt │ │ ├── header_2.txt │ │ ├── autoformat.expected │ │ ├── fields_4.txt │ │ ├── header_autoformat.expected │ │ ├── semicolon_fields_1.txt │ │ ├── header.expected │ │ ├── missing_format_fields.expected │ │ ├── different_field.expected │ │ ├── fields_2.txt │ │ ├── different_fields.expected │ │ ├── unpaired_lines_format.expected │ │ └── unpaired_lines.expected │ ├── cp │ │ ├── hello_dir │ │ │ └── hello.txt │ │ ├── hello_world.txt │ │ ├── how_are_you.txt │ │ ├── existing_file.txt │ │ └── hello_dir_with_file │ │ │ └── hello_world.txt │ ├── du │ │ ├── words.txt │ │ └── subdir │ │ │ ├── deeper │ │ │ └── words.txt │ │ │ └── links │ │ │ └── subwords2.txt │ ├── .gitattributes │ ├── hashsum │ │ ├── input.txt │ │ ├── md5.expected │ │ ├── sha1.expected │ │ ├── sha224.expected │ │ ├── sha3_224.expected │ │ ├── sha256.expected │ │ ├── sha3_256.expected │ │ ├── shake128_256.expected │ │ ├── sha384.expected │ │ ├── sha3_384.expected │ │ ├── sha3_512.expected │ │ ├── sha512.expected │ │ └── shake256_512.expected │ ├── ptx │ │ ├── ignore │ │ ├── only │ │ ├── gnu_ext_disabled_ignore_and_only_file.expected │ │ ├── input │ │ ├── gnu_ext_disabled_roff_input_ref.expected │ │ ├── gnu_ext_disabled_tex_input_ref.expected │ │ ├── gnu_ext_disabled_roff_no_ref.expected │ │ ├── gnu_ext_disabled_tex_no_ref.expected │ │ ├── gnu_ext_disabled_roff_auto_ref.expected │ │ └── gnu_ext_disabled_tex_auto_ref.expected │ ├── sum │ │ ├── bsd_stdin.expected │ │ ├── sysv_stdin.expected │ │ ├── bsd_single_file.expected │ │ ├── sysv_single_file.expected │ │ ├── bsd_multiple_files.expected │ │ ├── sysv_multiple_files.expected │ │ ├── alice_in_wonderland.txt │ │ └── lorem_ipsum.txt │ ├── tail │ │ ├── foobar2.txt │ │ ├── foobar_bytes_single.expected │ │ ├── foobar_bytes_stdin.expected │ │ ├── foobar_with_null.txt │ │ ├── foobar_follow_multiple_appended.expected │ │ ├── foobar_with_null_default.expected │ │ ├── follow_stdin.expected │ │ ├── foobar.txt │ │ ├── foobar_single_default.expected │ │ ├── foobar_stdin_default.expected │ │ ├── foobar_multiple_quiet.expected │ │ └── foobar_follow_multiple.expected │ ├── cksum │ │ ├── stdin.expected │ │ ├── single_file.expected │ │ ├── multiple_files.expected │ │ ├── alice_in_wonderland.txt │ │ └── lorem_ipsum.txt │ ├── head │ │ ├── lorem_ipsum_5_chars.expected │ │ ├── lorem_ipsum_1_line.expected │ │ ├── lorem_ipsum_default.expected │ │ ├── lorem_ipsum_verbose.expected │ │ └── lorem_ipsum.txt │ ├── mv │ │ └── hello_world.txt │ ├── sort │ │ ├── numeric_floats.txt │ │ ├── merge_ints_reversed_1.txt │ │ ├── merge_ints_reversed_2.txt │ │ ├── merge_ints_reversed_3.txt │ │ ├── multiple_files1.txt │ │ ├── numeric_fixed_floats.txt │ │ ├── numeric_floats.expected │ │ ├── numeric_floats_and_ints.txt │ │ ├── numeric_unfixed_floats.txt │ │ ├── merge_ints_interleaved_1.txt │ │ ├── merge_ints_interleaved_2.txt │ │ ├── merge_ints_interleaved_3.txt │ │ ├── numeric_fixed_floats.expected │ │ ├── numeric_floats_and_ints.expected │ │ ├── numeric_unfixed_floats.expected │ │ ├── multiple_files2.txt │ │ ├── numeric_floats_with_nan.txt │ │ ├── numeric_floats_with_nan.expected │ │ ├── check_fail.txt │ │ ├── numeric_unsorted_ints_unique.expected │ │ ├── version.txt │ │ ├── ignore_case.txt │ │ ├── version.expected │ │ ├── ignore_case.expected │ │ ├── numeric_unsorted_ints_unique.txt │ │ ├── multiple_files.expected │ │ ├── merge_ints_reversed.expected │ │ ├── merge_ints_interleaved.expected │ │ ├── human_block_sizes.txt │ │ ├── human_block_sizes.expected │ │ ├── month_default.txt │ │ ├── month_stable.txt │ │ ├── month_default.expected │ │ ├── month_stable.expected │ │ ├── default_unsorted_ints.txt │ │ ├── numeric_unsorted_ints.txt │ │ ├── default_unsorted_ints.expected │ │ └── numeric_unsorted_ints.expected │ ├── cat │ │ ├── nonewline.txt │ │ ├── alpha.txt │ │ └── 256.txt │ ├── uniq │ │ ├── skip-2-fields.expected │ │ ├── sorted-unique-only.expected │ │ ├── skip-5-chars.expected │ │ ├── skip-3-check-2-chars.expected │ │ ├── skip-3-check-5-chars.expected │ │ ├── sorted-repeated-only.expected │ │ ├── skip-1-char.expected │ │ ├── skip-fields.txt │ │ ├── sorted-zero-terminated.expected │ │ ├── sorted-ignore-case.expected │ │ ├── sorted-simple.expected │ │ ├── skip-chars.txt │ │ ├── sorted-counts.expected │ │ ├── sorted-zero-terminated.txt │ │ ├── sorted-all-repeated.expected │ │ ├── sorted.txt │ │ ├── sorted-all-repeated-separate.expected │ │ └── sorted-all-repeated-prepend.expected │ ├── cut │ │ ├── sequences │ │ │ ├── byte_singular.expected │ │ │ ├── byte_prefix.expected │ │ │ ├── byte_range.expected │ │ │ ├── field_prefix.expected │ │ │ ├── field_singular.expected │ │ │ ├── field_range.expected │ │ │ ├── byte_aggregate.expected │ │ │ ├── field_aggregate.expected │ │ │ ├── byte_subsumed.expected │ │ │ ├── byte_suffix.expected │ │ │ ├── field_subsumed.expected │ │ │ └── field_suffix.expected │ │ ├── delimiter_specified.expected │ │ ├── output_delimiter.expected │ │ └── lists.txt │ ├── env │ │ └── vars.conf.txt │ ├── tac │ │ ├── delimited_primes.txt │ │ ├── delimited_primes.expected │ │ ├── delimited_primes_before.expected │ │ ├── prime_per_line.txt │ │ └── prime_per_line.expected │ ├── dircolors │ │ ├── test1.csh.expected │ │ ├── test1.sh.expected │ │ ├── keywords.csh.expected │ │ ├── keywords.sh.expected │ │ ├── test1.txt │ │ ├── keywords.txt │ │ ├── csh_def.expected │ │ └── bash_def.expected │ ├── nl │ │ ├── simple.txt │ │ ├── section.txt │ │ └── joinblanklines.txt │ ├── tsort │ │ ├── call_graph.expected │ │ └── call_graph.txt │ ├── paste │ │ ├── html_colors.expected │ │ └── html_colors.txt │ ├── wc │ │ ├── alice_in_wonderland.txt │ │ ├── lorem_ipsum.txt │ │ └── moby_dick.txt │ └── fold │ │ ├── lorem_ipsum.txt │ │ ├── lorem_ipsum_80_column.expected │ │ ├── lorem_ipsum_40_column_hard.expected │ │ └── lorem_ipsum_40_column_word.expected ├── common │ ├── mod.rs │ └── macros.rs ├── test_false.rs ├── test_true.rs ├── test_pwd.rs ├── test_paste.rs ├── test_pathchk.rs ├── test_hostname.rs ├── test_stdbuf.rs ├── test_tsort.rs ├── test_ls.rs ├── test_cksum.rs ├── test_fold.rs ├── test_test.rs ├── test_seq.rs ├── test_dirname.rs ├── test_truncate.rs ├── test_realpath.rs ├── test_link.rs ├── test_tac.rs ├── test_sum.rs ├── test_unlink.rs ├── test_expr.rs ├── test_chown.rs ├── test_hashsum.rs ├── test_ptx.rs ├── test_mkdir.rs ├── test_wc.rs ├── test_head.rs └── test_readlink.rs ├── Makefile ├── .cargo └── config ├── docs ├── Makefile ├── index.rst ├── uutils.rst ├── GNUmakefile ├── arch.rst └── make.bat ├── .busybox-config ├── .codecov.yml ├── .gitignore ├── .travis └── redox-toolchain.sh ├── .cirrus.yml ├── util ├── rewrite_rules.rs ├── show-utils.sh ├── show-utils.BAT └── show-codecov.BAT └── LICENSE /src/uu/cut/.gitignore: -------------------------------------------------------------------------------- 1 | target -------------------------------------------------------------------------------- /tests/fixtures/comm/empty: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/od/0: -------------------------------------------------------------------------------- 1 | zero 2 | -------------------------------------------------------------------------------- /tests/fixtures/comm/a: -------------------------------------------------------------------------------- 1 | a 2 | z 3 | -------------------------------------------------------------------------------- /tests/fixtures/comm/b: -------------------------------------------------------------------------------- 1 | b 2 | z 3 | -------------------------------------------------------------------------------- /tests/fixtures/join/empty.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/cp/hello_dir/hello.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/du/words.txt: -------------------------------------------------------------------------------- 1 | hi 2 | -------------------------------------------------------------------------------- /tests/fixtures/od/c: -------------------------------------------------------------------------------- 1 | lowercase c 2 | -------------------------------------------------------------------------------- /tests/fixtures/od/x: -------------------------------------------------------------------------------- 1 | lowercase x 2 | -------------------------------------------------------------------------------- /tests/fixtures/comm/emptyempty.expected: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/od/-f: -------------------------------------------------------------------------------- 1 | minus lowercase f 2 | -------------------------------------------------------------------------------- /tests/fixtures/.gitattributes: -------------------------------------------------------------------------------- 1 | * -text diff 2 | -------------------------------------------------------------------------------- /tests/fixtures/comm/ab1.expected: -------------------------------------------------------------------------------- 1 | b 2 | z 3 | -------------------------------------------------------------------------------- /tests/fixtures/comm/ab2.expected: -------------------------------------------------------------------------------- 1 | a 2 | z 3 | -------------------------------------------------------------------------------- /tests/fixtures/comm/ab3.expected: -------------------------------------------------------------------------------- 1 | a 2 | b 3 | -------------------------------------------------------------------------------- /tests/fixtures/comm/aempty.expected: -------------------------------------------------------------------------------- 1 | a 2 | z 3 | -------------------------------------------------------------------------------- /tests/fixtures/comm/lowercase_uppercase: -------------------------------------------------------------------------------- 1 | a 2 | A -------------------------------------------------------------------------------- /tests/fixtures/hashsum/input.txt: -------------------------------------------------------------------------------- 1 | hello, world -------------------------------------------------------------------------------- /tests/fixtures/ptx/ignore: -------------------------------------------------------------------------------- 1 | maybe 2 | about 3 | -------------------------------------------------------------------------------- /tests/fixtures/sum/bsd_stdin.expected: -------------------------------------------------------------------------------- 1 | 8109 1 2 | -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar2.txt: -------------------------------------------------------------------------------- 1 | un 2 | deux 3 | -------------------------------------------------------------------------------- /tests/fixtures/cksum/stdin.expected: -------------------------------------------------------------------------------- 1 | 378294376 772 2 | -------------------------------------------------------------------------------- /tests/fixtures/comm/ab.expected: -------------------------------------------------------------------------------- 1 | a 2 | b 3 | z 4 | -------------------------------------------------------------------------------- /tests/fixtures/cp/hello_world.txt: -------------------------------------------------------------------------------- 1 | Hello, World! 2 | -------------------------------------------------------------------------------- /tests/fixtures/cp/how_are_you.txt: -------------------------------------------------------------------------------- 1 | How are you? 2 | -------------------------------------------------------------------------------- /tests/fixtures/du/subdir/deeper/words.txt: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /tests/fixtures/head/lorem_ipsum_5_chars.expected: -------------------------------------------------------------------------------- 1 | Lorem -------------------------------------------------------------------------------- /tests/fixtures/mv/hello_world.txt: -------------------------------------------------------------------------------- 1 | Hello, World! 2 | -------------------------------------------------------------------------------- /tests/fixtures/sum/sysv_stdin.expected: -------------------------------------------------------------------------------- 1 | 6985 2 2 | -------------------------------------------------------------------------------- /tests/fixtures/comm/bad_order_1: -------------------------------------------------------------------------------- 1 | e 2 | d 3 | b 4 | a 5 | -------------------------------------------------------------------------------- /tests/fixtures/comm/bad_order_2: -------------------------------------------------------------------------------- 1 | e 2 | c 3 | b 4 | a 5 | -------------------------------------------------------------------------------- /tests/fixtures/comm/lowercase_uppercase.c.expected: -------------------------------------------------------------------------------- 1 | a 2 | -------------------------------------------------------------------------------- /tests/fixtures/cp/existing_file.txt: -------------------------------------------------------------------------------- 1 | Cogito ergo sum. 2 | -------------------------------------------------------------------------------- /tests/fixtures/du/subdir/links/subwords2.txt: -------------------------------------------------------------------------------- 1 | hello 2 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_floats.txt: -------------------------------------------------------------------------------- 1 | .03 2 | .02 3 | -------------------------------------------------------------------------------- /tests/fixtures/sum/bsd_single_file.expected: -------------------------------------------------------------------------------- 1 | 8109 1 2 | -------------------------------------------------------------------------------- /tests/fixtures/cat/nonewline.txt: -------------------------------------------------------------------------------- 1 | text without a trailing newline -------------------------------------------------------------------------------- /tests/fixtures/comm/bad_order12.check_order.expected: -------------------------------------------------------------------------------- 1 | e 2 | -------------------------------------------------------------------------------- /tests/fixtures/join/fields_1.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 5 5 | 8 6 | -------------------------------------------------------------------------------- /tests/fixtures/sort/merge_ints_reversed_1.txt: -------------------------------------------------------------------------------- 1 | 7 2 | 4 3 | 1 4 | -------------------------------------------------------------------------------- /tests/fixtures/sort/merge_ints_reversed_2.txt: -------------------------------------------------------------------------------- 1 | 8 2 | 5 3 | 2 4 | -------------------------------------------------------------------------------- /tests/fixtures/sort/merge_ints_reversed_3.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 6 3 | 3 4 | -------------------------------------------------------------------------------- /tests/fixtures/sort/multiple_files1.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 7 3 | 2 4 | 5 5 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_fixed_floats.txt: -------------------------------------------------------------------------------- 1 | .01 2 | .00 3 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_floats.expected: -------------------------------------------------------------------------------- 1 | .02 2 | .03 3 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_floats_and_ints.txt: -------------------------------------------------------------------------------- 1 | .02 2 | 0 3 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_unfixed_floats.txt: -------------------------------------------------------------------------------- 1 | .01 2 | .000 3 | -------------------------------------------------------------------------------- /tests/fixtures/hashsum/md5.expected: -------------------------------------------------------------------------------- 1 | e4d7f1b4ed2e42d15898f4b27b019da4 -------------------------------------------------------------------------------- /tests/fixtures/join/capitalized.txt: -------------------------------------------------------------------------------- 1 | A 1 2 | B 2 3 | C 4 4 | D 8 5 | -------------------------------------------------------------------------------- /tests/fixtures/join/suppress_joined.expected: -------------------------------------------------------------------------------- 1 | 1 a 2 | 8 h 3 | 9 i 4 | -------------------------------------------------------------------------------- /tests/fixtures/sort/merge_ints_interleaved_1.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 4 3 | 7 4 | -------------------------------------------------------------------------------- /tests/fixtures/sort/merge_ints_interleaved_2.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 5 3 | 8 4 | -------------------------------------------------------------------------------- /tests/fixtures/sort/merge_ints_interleaved_3.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 6 3 | 9 4 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_fixed_floats.expected: -------------------------------------------------------------------------------- 1 | .00 2 | .01 3 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_floats_and_ints.expected: -------------------------------------------------------------------------------- 1 | 0 2 | .02 3 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_unfixed_floats.expected: -------------------------------------------------------------------------------- 1 | .000 2 | .01 3 | -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar_bytes_single.expected: -------------------------------------------------------------------------------- 1 | diez 2 | once 3 | -------------------------------------------------------------------------------- /src/common/uumain.rs: -------------------------------------------------------------------------------- 1 | include!(concat!(env!("OUT_DIR"), "/main.rs")); 2 | -------------------------------------------------------------------------------- /src/uu/printf/src/mod.rs: -------------------------------------------------------------------------------- 1 | mod cli; 2 | mod memo; 3 | mod tokenize; 4 | -------------------------------------------------------------------------------- /tests/fixtures/comm/lowercase_uppercase.en_us.expected: -------------------------------------------------------------------------------- 1 | a 2 | A 3 | -------------------------------------------------------------------------------- /tests/fixtures/cp/hello_dir_with_file/hello_world.txt: -------------------------------------------------------------------------------- 1 | Hello, World! 2 | -------------------------------------------------------------------------------- /tests/fixtures/join/semicolon_fields_2.txt: -------------------------------------------------------------------------------- 1 | 2 ;x 2 | 3; y 3 | 4 ;z 4 | -------------------------------------------------------------------------------- /tests/fixtures/ptx/only: -------------------------------------------------------------------------------- 1 | roff 2 | tex 3 | world 4 | maybe 5 | about 6 | -------------------------------------------------------------------------------- /tests/fixtures/sort/multiple_files2.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 8 3 | 1 4 | 9 5 | 6 6 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_floats_with_nan.txt: -------------------------------------------------------------------------------- 1 | .03 2 | .02 3 | NaN 4 | -------------------------------------------------------------------------------- /tests/fixtures/sum/sysv_single_file.expected: -------------------------------------------------------------------------------- 1 | 6985 2 lorem_ipsum.txt 2 | -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar_bytes_stdin.expected: -------------------------------------------------------------------------------- 1 | ve 2 | diez 3 | once 4 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/skip-2-fields.expected: -------------------------------------------------------------------------------- 1 | aaa aa a 2 | aa a 3 | -------------------------------------------------------------------------------- /tests/common/mod.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | pub mod macros; 3 | pub mod util; 4 | -------------------------------------------------------------------------------- /tests/fixtures/cksum/single_file.expected: -------------------------------------------------------------------------------- 1 | 378294376 772 lorem_ipsum.txt 2 | -------------------------------------------------------------------------------- /tests/fixtures/comm/ab_delimiter_word.expected: -------------------------------------------------------------------------------- 1 | a 2 | wordb 3 | wordwordz 4 | -------------------------------------------------------------------------------- /tests/fixtures/comm/defaultcheck_unintuitive_2: -------------------------------------------------------------------------------- 1 | m 2 | h 3 | n 4 | o 5 | p 6 | -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha1.expected: -------------------------------------------------------------------------------- 1 | b7e23ec29af22b0b4e41da31e868d57226121c84 -------------------------------------------------------------------------------- /tests/fixtures/join/default.expected: -------------------------------------------------------------------------------- 1 | 1 a 2 | 2 b 3 | 3 c 4 | 5 e 5 | 8 h 6 | -------------------------------------------------------------------------------- /tests/fixtures/join/empty_key.expected: -------------------------------------------------------------------------------- 1 | x 1 2 | x 2 3 | x 3 4 | x 5 5 | x 8 6 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_floats_with_nan.expected: -------------------------------------------------------------------------------- 1 | NaN 2 | .02 3 | .03 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | USEGNU=gmake $* 2 | all: 3 | @$(USEGNU) 4 | .DEFAULT: 5 | @$(USEGNU) 6 | -------------------------------------------------------------------------------- /tests/fixtures/cat/alpha.txt: -------------------------------------------------------------------------------- 1 | abcde 2 | fghij 3 | klmno 4 | pqrst 5 | uvwxyz 6 | -------------------------------------------------------------------------------- /tests/fixtures/comm/defaultcheck_unintuitive_1: -------------------------------------------------------------------------------- 1 | m 2 | h 3 | n 4 | o 5 | c 6 | p 7 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/byte_singular.expected: -------------------------------------------------------------------------------- 1 | o 2 | n 3 | l 4 | h 5 | a 6 | -------------------------------------------------------------------------------- /tests/fixtures/env/vars.conf.txt: -------------------------------------------------------------------------------- 1 | # comment 2 | FOO=bar 3 | 4 | BAR="bamf this" 5 | -------------------------------------------------------------------------------- /tests/fixtures/head/lorem_ipsum_1_line.expected: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, 2 | -------------------------------------------------------------------------------- /tests/fixtures/join/case_insensitive.expected: -------------------------------------------------------------------------------- 1 | A 1 2 f 2 | B 2 3 g 3 | C 4 4 h 4 | -------------------------------------------------------------------------------- /tests/fixtures/join/semicolon_separated.expected: -------------------------------------------------------------------------------- 1 | 2 ;b;x 2 | 3; c; y 3 | 4 ;d;z 4 | -------------------------------------------------------------------------------- /tests/fixtures/sort/check_fail.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 6 6 | 5 7 | 9 8 | 8 9 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_unsorted_ints_unique.expected: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-unique-only.expected: -------------------------------------------------------------------------------- 1 | aaaaa ⅰ 2 | eeeee ⅲ 3 | -------------------------------------------------------------------------------- /.cargo/config: -------------------------------------------------------------------------------- 1 | [target.x86_64-unknown-redox] 2 | linker = "x86_64-unknown-redox-gcc" 3 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | USEGNU=gmake $* 2 | all: 3 | @$(USEGNU) 4 | .DEFAULT: 5 | @$(USEGNU) 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/byte_prefix.expected: -------------------------------------------------------------------------------- 1 | fo 2 | on 3 | al 4 | th 5 | sa 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/byte_range.expected: -------------------------------------------------------------------------------- 1 | oo: 2 | ne: 3 | lph 4 | he 5 | all 6 | -------------------------------------------------------------------------------- /tests/fixtures/sort/version.txt: -------------------------------------------------------------------------------- 1 | 11.2.3 2 | 1.2.3-alpha2 3 | 1.2.3-alpha 4 | 1.12.4 5 | -------------------------------------------------------------------------------- /tests/fixtures/comm/bad_order11.defaultcheck_order.expected: -------------------------------------------------------------------------------- 1 | e 2 | d 3 | b 4 | a 5 | -------------------------------------------------------------------------------- /tests/fixtures/join/different_lengths.txt: -------------------------------------------------------------------------------- 1 | 1 a b 2 | 2 b c 3 | 3 d e f 4 | 4 g h 5 | 5 i 6 | -------------------------------------------------------------------------------- /tests/fixtures/join/fields_3.txt: -------------------------------------------------------------------------------- 1 | a 2 f 2 | b 3 g 3 | c 4 h 4 | f 5 i 5 | g 6 j 6 | h 7 k 7 | -------------------------------------------------------------------------------- /tests/fixtures/join/header_1.txt: -------------------------------------------------------------------------------- 1 | id field 2 | 1 a abc 3 | 2 b abc 4 | 3 c 5 | 4 d 6 | 5 c 7 | -------------------------------------------------------------------------------- /tests/fixtures/join/header_2.txt: -------------------------------------------------------------------------------- 1 | id count 2 | 1 10 3 | 2 25 4 | 4 17 xyz 5 | 7 18 xyz 6 | -------------------------------------------------------------------------------- /tests/fixtures/sort/ignore_case.txt: -------------------------------------------------------------------------------- 1 | aaa 2 | ccc 3 | eee 4 | ggg 5 | BBB 6 | DDD 7 | FFF 8 | -------------------------------------------------------------------------------- /tests/fixtures/sort/version.expected: -------------------------------------------------------------------------------- 1 | 1.2.3-alpha 2 | 1.2.3-alpha2 3 | 1.12.4 4 | 11.2.3 5 | -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha224.expected: -------------------------------------------------------------------------------- 1 | 6e1a93e32fb44081a401f3db3ef2e6e108b7bbeeb5705afdaf01fb27 -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha3_224.expected: -------------------------------------------------------------------------------- 1 | 927b362eaf84a75785bbec3370d1c9711349e93f1104eda060784221 -------------------------------------------------------------------------------- /tests/fixtures/join/autoformat.expected: -------------------------------------------------------------------------------- 1 | 1 a a b 2 | 2 b b c 3 | 3 c d e 4 | 4 d g h 5 | 5 e i 6 | -------------------------------------------------------------------------------- /tests/fixtures/join/fields_4.txt: -------------------------------------------------------------------------------- 1 | 2 c 1 cd 2 | 3 d 2 de 3 | 5 e 3 ef 4 | 7 f 4 fg 5 | 11 g 5 gh 6 | -------------------------------------------------------------------------------- /tests/fixtures/join/header_autoformat.expected: -------------------------------------------------------------------------------- 1 | id field count 2 | 1 a 10 3 | 2 b 25 4 | 4 d 17 5 | -------------------------------------------------------------------------------- /tests/fixtures/join/semicolon_fields_1.txt: -------------------------------------------------------------------------------- 1 | 1; a 2 | 2 ;b 3 | 3; c 4 | 4 ;d 5 | 5; e 6 | 6 ;f 7 | -------------------------------------------------------------------------------- /tests/fixtures/sort/ignore_case.expected: -------------------------------------------------------------------------------- 1 | aaa 2 | BBB 3 | ccc 4 | DDD 5 | eee 6 | FFF 7 | ggg 8 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_unsorted_ints_unique.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 2 3 | 4 4 | 3 5 | 3 6 | 2 7 | 1 8 | -------------------------------------------------------------------------------- /tests/fixtures/comm/bad_order12.nocheck_order.expected: -------------------------------------------------------------------------------- 1 | e 2 | c 3 | b 4 | a 5 | d 6 | b 7 | a 8 | -------------------------------------------------------------------------------- /tests/fixtures/comm/defaultcheck_unintuitive.expected: -------------------------------------------------------------------------------- 1 | m 2 | h 3 | n 4 | o 5 | c 6 | p 7 | -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha256.expected: -------------------------------------------------------------------------------- 1 | 09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b -------------------------------------------------------------------------------- /tests/fixtures/join/header.expected: -------------------------------------------------------------------------------- 1 | id field count 2 | 1 a abc 10 3 | 2 b abc 25 4 | 4 d 17 xyz 5 | -------------------------------------------------------------------------------- /tests/fixtures/join/missing_format_fields.expected: -------------------------------------------------------------------------------- 1 | 1 a x 2 | 2 b x 3 | 3 c f 4 | 4 d x 5 | 5 e x 6 | -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar_with_null.txt: -------------------------------------------------------------------------------- 1 | unodostresquattrocincoseissietteochonuevediezonce -------------------------------------------------------------------------------- /tests/fixtures/uniq/skip-5-chars.expected: -------------------------------------------------------------------------------- 1 | aaaaa 1 2 | Xbbbb 2 3 | ccccc 3 4 | XXXdd 1 5 | eeee 6 | -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha3_256.expected: -------------------------------------------------------------------------------- 1 | bfb3959527d7a3f2f09def2f6915452d55a8f122df9e164d6f31c7fcf6093e14 -------------------------------------------------------------------------------- /tests/fixtures/hashsum/shake128_256.expected: -------------------------------------------------------------------------------- 1 | 83d41db453072caa9953f2f316480fbbcb84a5f3505460a18b3a36a814ae8e9e -------------------------------------------------------------------------------- /tests/fixtures/sort/multiple_files.expected: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | -------------------------------------------------------------------------------- /tests/fixtures/sum/bsd_multiple_files.expected: -------------------------------------------------------------------------------- 1 | 8109 1 lorem_ipsum.txt 2 | 1814 1 alice_in_wonderland.txt 3 | -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar_follow_multiple_appended.expected: -------------------------------------------------------------------------------- 1 | 2 | ==> foobar.txt <== 3 | doce 4 | trece 5 | -------------------------------------------------------------------------------- /tests/fixtures/cat/256.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sagiegurari/coreutils/master/tests/fixtures/cat/256.txt -------------------------------------------------------------------------------- /tests/fixtures/sort/merge_ints_reversed.expected: -------------------------------------------------------------------------------- 1 | 9 2 | 8 3 | 7 4 | 6 5 | 5 6 | 4 7 | 3 8 | 2 9 | 1 10 | -------------------------------------------------------------------------------- /tests/fixtures/sum/sysv_multiple_files.expected: -------------------------------------------------------------------------------- 1 | 6985 2 lorem_ipsum.txt 2 | 27441 1 alice_in_wonderland.txt 3 | -------------------------------------------------------------------------------- /tests/fixtures/tac/delimited_primes.txt: -------------------------------------------------------------------------------- 1 | 2:3:5:7:11:13:17:19:23:29:31:37:41:43:47:53:59:61:67:71:73:79:83:89:97 -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar_with_null_default.expected: -------------------------------------------------------------------------------- 1 | dostresquattrocincoseissietteochonuevediezonce -------------------------------------------------------------------------------- /tests/fixtures/join/different_field.expected: -------------------------------------------------------------------------------- 1 | 2 b a f 2 | 3 c b g 3 | 4 d c h 4 | 5 e f i 5 | 6 f g j 6 | 7 g h k 7 | -------------------------------------------------------------------------------- /tests/fixtures/join/fields_2.txt: -------------------------------------------------------------------------------- 1 | 1 a 2 | 2 b 3 | 3 c 4 | 4 d 5 | 5 e 6 | 6 f 7 | 7 g 8 | 8 h 9 | 9 i 10 | -------------------------------------------------------------------------------- /tests/fixtures/sort/merge_ints_interleaved.expected: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | -------------------------------------------------------------------------------- /tests/fixtures/tac/delimited_primes.expected: -------------------------------------------------------------------------------- 1 | 9789:83:79:73:71:67:61:59:53:47:43:41:37:31:29:23:19:17:13:11:7:5:3:2: -------------------------------------------------------------------------------- /tests/fixtures/uniq/skip-3-check-2-chars.expected: -------------------------------------------------------------------------------- 1 | aaaaa 1 2 | Xbbbb 2 3 | ccccc 3 4 | Xdddd 3 5 | eeee 6 | fff 7 | -------------------------------------------------------------------------------- /.busybox-config: -------------------------------------------------------------------------------- 1 | CONFIG_FEATURE_FANCY_HEAD=y 2 | CONFIG_UNICODE_SUPPORT=y 3 | CONFIG_DESKTOP=y 4 | CONFIG_LONG_OPTS=y 5 | -------------------------------------------------------------------------------- /tests/fixtures/cksum/multiple_files.expected: -------------------------------------------------------------------------------- 1 | 378294376 772 lorem_ipsum.txt 2 | 3805907707 302 alice_in_wonderland.txt 3 | -------------------------------------------------------------------------------- /tests/fixtures/dircolors/test1.csh.expected: -------------------------------------------------------------------------------- 1 | setenv LS_COLORS '*.xspf=00;36:no=00:fi=00:su=37;41:sg=30;43:ca=30;41:' 2 | -------------------------------------------------------------------------------- /tests/fixtures/join/different_fields.expected: -------------------------------------------------------------------------------- 1 | c 3 2 1 cd 2 | d 4 3 2 de 3 | e 5 5 3 ef 4 | f 6 7 4 fg 5 | g 7 11 5 gh 6 | -------------------------------------------------------------------------------- /tests/fixtures/tac/delimited_primes_before.expected: -------------------------------------------------------------------------------- 1 | 97:89:83:79:73:71:67:61:59:53:47:43:41:37:31:29:23:19:17:13:11:7:5:3:2 -------------------------------------------------------------------------------- /tests/test_false.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_exit_code() { 5 | new_ucmd!().fails(); 6 | } 7 | -------------------------------------------------------------------------------- /tests/fixtures/join/unpaired_lines_format.expected: -------------------------------------------------------------------------------- 1 | f 2 a 2 | g 3 b 3 | h 4 c 4 | i 5 f 5 | j 6 g 6 | k 7 h 7 | -------------------------------------------------------------------------------- /tests/test_true.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_exit_code() { 5 | new_ucmd!().succeeds(); 6 | } 7 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | informational: true 8 | -------------------------------------------------------------------------------- /src/uu/printf/src/tokenize/num_format/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod format_field; 2 | mod formatter; 3 | mod formatters; 4 | pub mod num_format; 5 | -------------------------------------------------------------------------------- /tests/fixtures/dircolors/test1.sh.expected: -------------------------------------------------------------------------------- 1 | LS_COLORS='*.xspf=00;36:no=00:fi=00:su=37;41:sg=30;43:ca=30;41:'; 2 | export LS_COLORS 3 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/skip-3-check-5-chars.expected: -------------------------------------------------------------------------------- 1 | aaaaa 1 2 | Xbbbb 2 3 | ccccc 3 4 | Xdddd 3 5 | XXXdd 1 6 | eeee 7 | fff 8 | -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha384.expected: -------------------------------------------------------------------------------- 1 | 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha3_384.expected: -------------------------------------------------------------------------------- 1 | fbd0c5931195aaa9517869972b372f717bb69f7f9f72bfc0884ed0531c36a16fc2db5dd6d82131968b23ffe0e90757e5 -------------------------------------------------------------------------------- /tests/fixtures/ptx/gnu_ext_disabled_ignore_and_only_file.expected: -------------------------------------------------------------------------------- 1 | .xx "" """quotes"", for" "roff" "" 2 | .xx "" "{brackets} for" "tex" "" 3 | -------------------------------------------------------------------------------- /tests/fixtures/sort/human_block_sizes.txt: -------------------------------------------------------------------------------- 1 | 14M 2 | 20M 3 | 20P 4 | 11M 5 | 981T 6 | 16M 7 | 18M 8 | 19M 9 | 844K 10 | 981K 11 | 13M 12 | -------------------------------------------------------------------------------- /tests/fixtures/tail/follow_stdin.expected: -------------------------------------------------------------------------------- 1 | dos 2 | tres 3 | quattro 4 | cinco 5 | seis 6 | siette 7 | ocho 8 | nueve 9 | diez 10 | once 11 | -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar.txt: -------------------------------------------------------------------------------- 1 | uno 2 | dos 3 | tres 4 | quattro 5 | cinco 6 | seis 7 | siette 8 | ocho 9 | nueve 10 | diez 11 | once 12 | -------------------------------------------------------------------------------- /tests/fixtures/join/unpaired_lines.expected: -------------------------------------------------------------------------------- 1 | 1 a 2 | 2 a f b 3 | 3 b g c 4 | 4 c h d 5 | 5 f i e 6 | 6 g j f 7 | 7 h k g 8 | 8 h 9 | 9 i 10 | -------------------------------------------------------------------------------- /tests/fixtures/sort/human_block_sizes.expected: -------------------------------------------------------------------------------- 1 | 844K 2 | 981K 3 | 11M 4 | 13M 5 | 14M 6 | 16M 7 | 18M 8 | 19M 9 | 20M 10 | 981T 11 | 20P 12 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-repeated-only.expected: -------------------------------------------------------------------------------- 1 | bbbbb ⅱ 2 | ccccc ⅲ 3 | ddddd ⅲ 4 | fffff ⅲ 5 | ggggg ⅲ 6 | GGGGG ⅲ 7 | -------------------------------------------------------------------------------- /src/uu/printf/src/tokenize/mod.rs: -------------------------------------------------------------------------------- 1 | #[allow(clippy::module_inception)] 2 | mod num_format; 3 | pub mod sub; 4 | pub mod token; 5 | pub mod unescaped_text; 6 | -------------------------------------------------------------------------------- /tests/fixtures/nl/simple.txt: -------------------------------------------------------------------------------- 1 | L1 2 | L2 3 | L3 4 | L4 5 | L5 6 | L6 7 | L7 8 | L8 9 | L9 10 | L10 11 | L11 12 | L12 13 | L13 14 | L14 15 | L15 16 | -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar_single_default.expected: -------------------------------------------------------------------------------- 1 | dos 2 | tres 3 | quattro 4 | cinco 5 | seis 6 | siette 7 | ocho 8 | nueve 9 | diez 10 | once 11 | -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar_stdin_default.expected: -------------------------------------------------------------------------------- 1 | dos 2 | tres 3 | quattro 4 | cinco 5 | seis 6 | siette 7 | ocho 8 | nueve 9 | diez 10 | once 11 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/skip-1-char.expected: -------------------------------------------------------------------------------- 1 | aaaaa 1 2 | Xbbbb 2 3 | XXbbb 2 4 | ccccc 3 5 | Xdddd 3 6 | XXddd 3 7 | XXXdd 1 8 | eeee 9 | fff 10 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/skip-fields.txt: -------------------------------------------------------------------------------- 1 | aaa aa a 2 | ZZZ aa a 3 | ZZZ aa a 4 | ZZZ bb a 5 | ZZZ bb a 6 | aa a 7 | a 8 | 9 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-zero-terminated.expected: -------------------------------------------------------------------------------- 1 | aaaaa ⅰ bbbbb ⅱ ccccc ⅲ ddddd ⅲ eeeee ⅲ fffff ⅲ ggggg ⅲ GGGGG ⅲ -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha3_512.expected: -------------------------------------------------------------------------------- 1 | 2ed3a863a12e2f8ff140aa86232ff3603a7f24af62f0e2ca74672494ade175a9a3de42a351b5019d931a1deae0499609038d9b47268779d76198e1d410d20974 -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha512.expected: -------------------------------------------------------------------------------- 1 | 8710339dcb6814d0d9d2290ef422285c9322b7163951f9a0ca8f883d3305286f44139aa374848e4174f5aada663027e4548637b6d19894aec4fb6c46a139fbf9 -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-ignore-case.expected: -------------------------------------------------------------------------------- 1 | aaaaa ⅰ 2 | bbbbb ⅱ 3 | ccccc ⅲ 4 | ddddd ⅲ 5 | eeeee ⅲ 6 | fffff ⅲ 7 | ggggg ⅲ 8 | -------------------------------------------------------------------------------- /tests/fixtures/hashsum/shake256_512.expected: -------------------------------------------------------------------------------- 1 | 7c9896ea84a2a1b80b2183a3f2b4e43cd59b7d48471dc213bcedaccb699d6e6f7ad5d304928ab79329f1fc62f6db072d95b51209eb807683f5c9371872a2dd4e -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar_multiple_quiet.expected: -------------------------------------------------------------------------------- 1 | dos 2 | tres 3 | quattro 4 | cinco 5 | seis 6 | siette 7 | ocho 8 | nueve 9 | diez 10 | once 11 | un 12 | deux 13 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-simple.expected: -------------------------------------------------------------------------------- 1 | aaaaa ⅰ 2 | bbbbb ⅱ 3 | ccccc ⅲ 4 | ddddd ⅲ 5 | eeeee ⅲ 6 | fffff ⅲ 7 | ggggg ⅲ 8 | GGGGG ⅲ 9 | -------------------------------------------------------------------------------- /src/uu/stdbuf/src/libstdbuf/build.rs: -------------------------------------------------------------------------------- 1 | extern crate cpp_build; 2 | 3 | use cpp_build::Config; 4 | 5 | fn main() { 6 | Config::new().pic(true).build("src/libstdbuf.rs"); 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | /src/*/gen_table 3 | /build/ 4 | /tmp/ 5 | /busybox/ 6 | /.vscode/ 7 | /.vs/ 8 | *~ 9 | .*.swp 10 | .*.swo 11 | .idea 12 | Cargo.lock 13 | lib*.a 14 | /docs/_build -------------------------------------------------------------------------------- /tests/fixtures/uniq/skip-chars.txt: -------------------------------------------------------------------------------- 1 | aaaaa 1 2 | Xbbbb 2 3 | XXbbb 2 4 | ccccc 3 5 | Xcccc 3 6 | ccccc 3 7 | Xdddd 3 8 | XXddd 3 9 | XXXdd 1 10 | XXXdd 1 11 | eeee 12 | fff 13 | -------------------------------------------------------------------------------- /tests/test_pwd.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_default() { 5 | let (at, mut ucmd) = at_and_ucmd!(); 6 | ucmd.run().stdout_is(at.root_dir_resolved() + "\n"); 7 | } 8 | -------------------------------------------------------------------------------- /tests/fixtures/ptx/input: -------------------------------------------------------------------------------- 1 | hello world! 2 | let's check special characters: 3 | "quotes", for roff 4 | {brackets} for tex 5 | and some other like %a, b#, c$c 6 | maybe also~or^ 7 | oh, and back\slash 8 | -------------------------------------------------------------------------------- /src/uu/printf/src/tokenize/num_format/formatters/mod.rs: -------------------------------------------------------------------------------- 1 | mod base_conv; 2 | pub mod cninetyninehexfloatf; 3 | pub mod decf; 4 | mod float_common; 5 | pub mod floatf; 6 | pub mod intf; 7 | pub mod scif; 8 | -------------------------------------------------------------------------------- /tests/fixtures/tail/foobar_follow_multiple.expected: -------------------------------------------------------------------------------- 1 | ==> foobar.txt <== 2 | dos 3 | tres 4 | quattro 5 | cinco 6 | seis 7 | siette 8 | ocho 9 | nueve 10 | diez 11 | once 12 | 13 | ==> foobar2.txt <== 14 | un 15 | deux 16 | -------------------------------------------------------------------------------- /tests/fixtures/tac/prime_per_line.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 5 4 | 7 5 | 11 6 | 13 7 | 17 8 | 19 9 | 23 10 | 29 11 | 31 12 | 37 13 | 41 14 | 43 15 | 47 16 | 53 17 | 59 18 | 61 19 | 67 20 | 71 21 | 73 22 | 79 23 | 83 24 | 89 25 | 97 26 | -------------------------------------------------------------------------------- /tests/fixtures/tac/prime_per_line.expected: -------------------------------------------------------------------------------- 1 | 97 2 | 89 3 | 83 4 | 79 5 | 73 6 | 71 7 | 67 8 | 61 9 | 59 10 | 53 11 | 47 12 | 43 13 | 41 14 | 37 15 | 31 16 | 29 17 | 23 18 | 19 19 | 17 20 | 13 21 | 11 22 | 7 23 | 5 24 | 3 25 | 2 26 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-counts.expected: -------------------------------------------------------------------------------- 1 | 1 aaaaa ⅰ 2 | 2 bbbbb ⅱ 3 | 3 ccccc ⅲ 4 | 4 ddddd ⅲ 5 | 1 eeeee ⅲ 6 | 2 fffff ⅲ 7 | 3 ggggg ⅲ 8 | 2 GGGGG ⅲ 9 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/field_prefix.expected: -------------------------------------------------------------------------------- 1 | foo:bar:baz:qux:quux 2 | one:two:three:four:five:six:seven 3 | alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | the quick brown fox jumps over the lazy dog 5 | sally sells 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/field_singular.expected: -------------------------------------------------------------------------------- 1 | foo:bar:baz:qux:quux 2 | one:two:three:four:five:six:seven 3 | alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | the quick brown fox jumps over the lazy dog 5 | sells 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/field_range.expected: -------------------------------------------------------------------------------- 1 | foo:bar:baz:qux:quux 2 | one:two:three:four:five:six:seven 3 | alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | the quick brown fox jumps over the lazy dog 5 | sells seashells down 6 | -------------------------------------------------------------------------------- /tests/fixtures/dircolors/keywords.csh.expected: -------------------------------------------------------------------------------- 1 | setenv LS_COLORS 'no=00:fi=00:rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:lc=\e[:rc=m:ec=\xff:' 2 | -------------------------------------------------------------------------------- /tests/fixtures/nl/section.txt: -------------------------------------------------------------------------------- 1 | \:\:\: 2 | HEADER1 3 | HEADER2 4 | \:\: 5 | BODY1 6 | BODY2 7 | \: 8 | FOOTER1 9 | FOOTER2 10 | \:\:\: 11 | NEXTHEADER1 12 | NEXTHEADER2 13 | \:\: 14 | NEXTBODY1 15 | NEXTBODY2 16 | \: 17 | NEXTFOOTER1 18 | NEXTFOOTER2 19 | -------------------------------------------------------------------------------- /tests/fixtures/cut/delimiter_specified.expected: -------------------------------------------------------------------------------- 1 | foo:bar:qux 2 | one:two:four:six:seven 3 | alpha:beta:delta:zeta:eta:iota:kappa:lambda:mu 4 | the quick brown fox jumps over the lazy dog 5 | sally sells seashells down by the seashore where are the seashells sally sells 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/output_delimiter.expected: -------------------------------------------------------------------------------- 1 | foo@bar@qux 2 | one@two@four@six@seven 3 | alpha@beta@delta@zeta@eta@iota@kappa@lambda@mu 4 | the quick brown fox jumps over the lazy dog 5 | sally sells seashells down by the seashore where are the seashells sally sells 6 | -------------------------------------------------------------------------------- /tests/test_paste.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_combine_pairs_of_lines() { 5 | new_ucmd!() 6 | .args(&["-s", "-d", "\t\n", "html_colors.txt"]) 7 | .run() 8 | .stdout_is_fixture("html_colors.expected"); 9 | } 10 | -------------------------------------------------------------------------------- /tests/fixtures/dircolors/keywords.sh.expected: -------------------------------------------------------------------------------- 1 | LS_COLORS='no=00:fi=00:rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:lc=\e[:rc=m:ec=\xff:'; 2 | export LS_COLORS 3 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-zero-terminated.txt: -------------------------------------------------------------------------------- 1 | aaaaa ⅰ bbbbb ⅱ bbbbb ⅱ ccccc ⅲ ccccc ⅲ ccccc ⅲ ddddd ⅲ ddddd ⅲ ddddd ⅲ ddddd ⅲ eeeee ⅲ fffff ⅲ fffff ⅲ ggggg ⅲ ggggg ⅲ ggggg ⅲ GGGGG ⅲ GGGGG ⅲ -------------------------------------------------------------------------------- /tests/fixtures/cut/lists.txt: -------------------------------------------------------------------------------- 1 | foo:bar:baz:qux:quux 2 | one:two:three:four:five:six:seven 3 | alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | the quick brown fox jumps over the lazy dog 5 | sally sells seashells down by the seashore where are the seashells sally sells 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/byte_aggregate.expected: -------------------------------------------------------------------------------- 1 | fo:arbaz:qux:quux 2 | on:wothree:four:five:six:seven 3 | alh:bta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | th uik brown fox jumps over the lazy dog 5 | sal slls seashells down by the seashore where are the seashells sally sells 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/field_aggregate.expected: -------------------------------------------------------------------------------- 1 | foo:bar:baz:qux:quux 2 | one:two:three:four:five:six:seven 3 | alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | the quick brown fox jumps over the lazy dog 5 | sally sells down the seashore are the seashells sally sells 6 | -------------------------------------------------------------------------------- /tests/fixtures/nl/joinblanklines.txt: -------------------------------------------------------------------------------- 1 | Nonempty 2 | Nonempty 3 | Followed by 10x empty 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Followed by 5x empty 15 | 16 | 17 | 18 | 19 | 20 | Followed by 4x empty 21 | 22 | 23 | 24 | 25 | Nonempty 26 | Nonempty 27 | Nonempty. 28 | -------------------------------------------------------------------------------- /tests/fixtures/tsort/call_graph.expected: -------------------------------------------------------------------------------- 1 | main 2 | parse_options 3 | tail_file 4 | tail_forever 5 | tail 6 | recheck 7 | write_header 8 | tail_lines 9 | tail_bytes 10 | pretty_name 11 | start_lines 12 | file_lines 13 | pipe_lines 14 | xlseek 15 | start_bytes 16 | pipe_bytes 17 | dump_remainder 18 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/byte_subsumed.expected: -------------------------------------------------------------------------------- 1 | oo:bar:baz:qux:quux 2 | ne:two:three:four:five:six:seven 3 | lpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | he quick brown fox jumps over the lazy dog 5 | ally sells seashells down by the seashore where are the seashells sally sells 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/byte_suffix.expected: -------------------------------------------------------------------------------- 1 | oo:bar:baz:qux:quux 2 | ne:two:three:four:five:six:seven 3 | lpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | he quick brown fox jumps over the lazy dog 5 | ally sells seashells down by the seashore where are the seashells sally sells 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/field_subsumed.expected: -------------------------------------------------------------------------------- 1 | foo:bar:baz:qux:quux 2 | one:two:three:four:five:six:seven 3 | alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | the quick brown fox jumps over the lazy dog 5 | sells seashells down by the seashore where are the seashells sally sells 6 | -------------------------------------------------------------------------------- /tests/fixtures/cut/sequences/field_suffix.expected: -------------------------------------------------------------------------------- 1 | foo:bar:baz:qux:quux 2 | one:two:three:four:five:six:seven 3 | alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 4 | the quick brown fox jumps over the lazy dog 5 | sells seashells down by the seashore where are the seashells sally sells 6 | -------------------------------------------------------------------------------- /src/uu/split/README.md: -------------------------------------------------------------------------------- 1 | # Rudimentary "split" Implementation 2 | 3 | ## Missing Features 4 | 5 | ### Flags 6 | * `--verbose` - created file printing is implemented, don't know if there is anything else 7 | 8 | ## Possible Optimizations 9 | * Use slice (`[u8]`) directly as the `control.current_line`. 10 | -------------------------------------------------------------------------------- /.travis/redox-toolchain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rustup target add x86_64-unknown-redox 4 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA12E97F0881517F 5 | sudo add-apt-repository 'deb https://static.redox-os.org/toolchain/apt /' 6 | sudo apt-get update -qq 7 | sudo apt-get install -y x86-64-unknown-redox-gcc 8 | -------------------------------------------------------------------------------- /src/uu/cksum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cksum" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | 7 | [lib] 8 | name = "uu_cksum" 9 | path = "src/cksum.rs" 10 | 11 | [dependencies] 12 | libc = "0.2.42" 13 | uucore = "0.0.2" 14 | 15 | [[bin]] 16 | name = "cksum" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/factor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "factor" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | 7 | [lib] 8 | name = "uu_factor" 9 | path = "src/factor.rs" 10 | 11 | [dependencies] 12 | rand = "0.5" 13 | uucore = "0.0.2" 14 | 15 | [[bin]] 16 | name = "factor" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-all-repeated.expected: -------------------------------------------------------------------------------- 1 | bbbbb ⅱ 2 | bbbbb ⅱ 3 | ccccc ⅲ 4 | ccccc ⅲ 5 | ccccc ⅲ 6 | ddddd ⅲ 7 | ddddd ⅲ 8 | ddddd ⅲ 9 | ddddd ⅲ 10 | fffff ⅲ 11 | fffff ⅲ 12 | ggggg ⅲ 13 | ggggg ⅲ 14 | ggggg ⅲ 15 | GGGGG ⅲ 16 | GGGGG ⅲ 17 | -------------------------------------------------------------------------------- /src/uu/cut/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cut" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_cut" 10 | path = "src/cut.rs" 11 | 12 | [dependencies] 13 | uucore = "0.0.2" 14 | 15 | [[bin]] 16 | name = "cut" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/echo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "echo" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_echo" 10 | path = "src/echo.rs" 11 | 12 | [dependencies] 13 | uucore = "0.0.2" 14 | 15 | [[bin]] 16 | name = "echo" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/fold/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fold" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_fold" 10 | path = "src/fold.rs" 11 | 12 | [dependencies] 13 | uucore = "0.0.2" 14 | 15 | [[bin]] 16 | name = "fold" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/true/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "true" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_true" 10 | path = "src/true.rs" 11 | 12 | [dependencies] 13 | uucore = "0.0.2" 14 | 15 | [[bin]] 16 | name = "true" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /tests/fixtures/paste/html_colors.expected: -------------------------------------------------------------------------------- 1 | white #FFFFFF 2 | silver #C0C0C0 3 | gray #808080 4 | black #000000 5 | red #FF0000 6 | maroon #800000 7 | yellow #FFFF00 8 | olive #808000 9 | lime #00FF00 10 | green #008000 11 | aqua #00FFFF 12 | teal #008080 13 | blue #0000FF 14 | navy #000080 15 | fuchsia #FF00FF 16 | purple #800080 17 | -------------------------------------------------------------------------------- /src/uu/false/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "false" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_false" 10 | path = "src/false.rs" 11 | 12 | [dependencies] 13 | uucore = "0.0.2" 14 | 15 | [[bin]] 16 | name = "false" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/du/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "du" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_du" 10 | path = "src/du.rs" 11 | 12 | [dependencies] 13 | time = "0.1.40" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "du" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/ln/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ln" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_ln" 10 | path = "src/ln.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "ln" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted.txt: -------------------------------------------------------------------------------- 1 | aaaaa ⅰ 2 | bbbbb ⅱ 3 | bbbbb ⅱ 4 | ccccc ⅲ 5 | ccccc ⅲ 6 | ccccc ⅲ 7 | ddddd ⅲ 8 | ddddd ⅲ 9 | ddddd ⅲ 10 | ddddd ⅲ 11 | eeeee ⅲ 12 | fffff ⅲ 13 | fffff ⅲ 14 | ggggg ⅲ 15 | ggggg ⅲ 16 | ggggg ⅲ 17 | GGGGG ⅲ 18 | GGGGG ⅲ 19 | -------------------------------------------------------------------------------- /src/uu/mv/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mv" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_mv" 10 | path = "src/mv.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "mv" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/wc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wc" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_wc" 10 | path = "src/wc.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "wc" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /tests/fixtures/wc/alice_in_wonderland.txt: -------------------------------------------------------------------------------- 1 | Alice was beginning to get very tired of sitting by 2 | her sister on the bank, and of having nothing to do: once or twice 3 | she had peeped into the book her sister was reading, but it had no 4 | pictures or conversations in it, "and what is the use of a book," 5 | thought Alice "without pictures or conversation?" 6 | -------------------------------------------------------------------------------- /src/uu/basename/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basename" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_basename" 10 | path = "src/basename.rs" 11 | 12 | [dependencies] 13 | uucore = "0.0.2" 14 | 15 | [[bin]] 16 | name = "basename" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/head/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "head" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_head" 10 | path = "src/head.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "head" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/join/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "join" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_join" 10 | path = "src/join.rs" 11 | 12 | [dependencies] 13 | clap = "2.32.0" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "join" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/link/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "link" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_link" 10 | path = "src/link.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "link" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/pwd/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pwd" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_pwd" 10 | path = "src/pwd.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "pwd" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/seq/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "seq" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_seq" 10 | path = "src/seq.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "seq" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/sum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sum" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_sum" 10 | path = "src/sum.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "sum" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/tac/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tac" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_tac" 10 | path = "src/tac.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "tac" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /tests/fixtures/cksum/alice_in_wonderland.txt: -------------------------------------------------------------------------------- 1 | Alice was beginning to get very tired of sitting by 2 | her sister on the bank, and of having nothing to do: once or twice 3 | she had peeped into the book her sister was reading, but it had no 4 | pictures or conversations in it, "and what is the use of a book," 5 | thought Alice "without pictures or conversation?" 6 | -------------------------------------------------------------------------------- /tests/fixtures/sum/alice_in_wonderland.txt: -------------------------------------------------------------------------------- 1 | Alice was beginning to get very tired of sitting by 2 | her sister on the bank, and of having nothing to do: once or twice 3 | she had peeped into the book her sister was reading, but it had no 4 | pictures or conversations in it, "and what is the use of a book," 5 | thought Alice "without pictures or conversation?" 6 | -------------------------------------------------------------------------------- /src/uu/uniq/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uniq" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_uniq" 10 | path = "src/uniq.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "uniq" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/arch/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "arch" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_arch" 10 | path = "src/arch.rs" 11 | 12 | [dependencies] 13 | platform-info = "0.0.1" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "arch" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/hostid/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hostid" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_hostid" 10 | path = "src/hostid.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "hostid" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/paste/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "paste" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_paste" 10 | path = "src/paste.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "paste" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/rmdir/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rmdir" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_rmdir" 10 | path = "src/rmdir.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "rmdir" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/split/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "split" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_split" 10 | path = "src/split.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "split" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/tsort/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tsort" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_tsort" 10 | path = "src/tsort.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "tsort" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-all-repeated-separate.expected: -------------------------------------------------------------------------------- 1 | bbbbb ⅱ 2 | bbbbb ⅱ 3 | 4 | ccccc ⅲ 5 | ccccc ⅲ 6 | ccccc ⅲ 7 | 8 | ddddd ⅲ 9 | ddddd ⅲ 10 | ddddd ⅲ 11 | ddddd ⅲ 12 | 13 | fffff ⅲ 14 | fffff ⅲ 15 | 16 | ggggg ⅲ 17 | ggggg ⅲ 18 | ggggg ⅲ 19 | 20 | GGGGG ⅲ 21 | GGGGG ⅲ 22 | -------------------------------------------------------------------------------- /src/uu/dirname/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dirname" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_dirname" 10 | path = "src/dirname.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "dirname" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/logname/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "logname" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_logname" 10 | path = "src/logname.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "logname" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/numfmt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "numfmt" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_numfmt" 10 | path = "src/numfmt.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "numfmt" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-all-repeated-prepend.expected: -------------------------------------------------------------------------------- 1 | 2 | bbbbb ⅱ 3 | bbbbb ⅱ 4 | 5 | ccccc ⅲ 6 | ccccc ⅲ 7 | ccccc ⅲ 8 | 9 | ddddd ⅲ 10 | ddddd ⅲ 11 | ddddd ⅲ 12 | ddddd ⅲ 13 | 14 | fffff ⅲ 15 | fffff ⅲ 16 | 17 | ggggg ⅲ 18 | ggggg ⅲ 19 | ggggg ⅲ 20 | 21 | GGGGG ⅲ 22 | GGGGG ⅲ 23 | -------------------------------------------------------------------------------- /src/uu/date/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "date" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_date" 10 | path = "src/date.rs" 11 | 12 | [dependencies] 13 | chrono = "0.4.4" 14 | clap = "2.32.0" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "date" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/expr/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "expr" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_expr" 10 | path = "src/expr.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | onig = "~4.3.2" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "expr" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/id/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "id" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_id" 10 | path = "src/id.rs" 11 | 12 | [dependencies] 13 | uucore = { version = "0.0.2", features = ["entries", "process"] } 14 | 15 | [[bin]] 16 | name = "id" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/shuf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "shuf" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_shuf" 10 | path = "src/shuf.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | rand = "0.5" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "shuf" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/tee/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tee" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_tee" 10 | path = "src/tee.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "tee" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/comm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "comm" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_comm" 10 | path = "src/comm.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "comm" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/dircolors/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dircolors" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_dircolors" 10 | path = "src/dircolors.rs" 11 | 12 | [dependencies] 13 | glob = "0.3.0" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "dircolors" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/fmt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fmt" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_fmt" 10 | path = "src/fmt.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | unicode-width = "0.1.5" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "fmt" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/groups/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "groups" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_groups" 10 | path = "src/groups.rs" 11 | 12 | [dependencies] 13 | uucore = { version = "0.0.2", features = ["entries"] } 14 | 15 | [[bin]] 16 | name = "groups" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/nice/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nice" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_nice" 10 | path = "src/nice.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "nice" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/printenv/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "printenv" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_printenv" 10 | path = "src/printenv.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "printenv" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/printf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "printf" 3 | version = "0.0.1" 4 | authors = ["Nathan Ross"] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_printf" 10 | path = "src/printf.rs" 11 | 12 | [dependencies] 13 | itertools = "0.8.0" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "printf" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/truncate/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "truncate" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_truncate" 10 | path = "src/truncate.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [[bin]] 17 | name = "truncate" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/base64/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "base64" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_base64" 10 | path = "src/base64.rs" 11 | 12 | [dependencies] 13 | uucore = { version = "0.0.2", features = ["encoding"] } 14 | 15 | [[bin]] 16 | name = "base64" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/mkdir/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mkdir" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_mkdir" 10 | path = "src/mkdir.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "mkdir" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/mknod/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mknod" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_mknod" 10 | path = "src/mknod.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "^0.2.42" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "mknod" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/pinky/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pinky" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_pinky" 10 | path = "src/pinky.rs" 11 | 12 | [dependencies] 13 | uucore = { version = "0.0.2", features = ["utmpx", "entries"] } 14 | 15 | [[bin]] 16 | name = "pinky" 17 | path = "../../common/uumain.rs" 18 | -------------------------------------------------------------------------------- /src/uu/mkfifo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mkfifo" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_mkfifo" 10 | path = "src/mkfifo.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "mkfifo" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/tr/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tr" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_tr" 10 | path = "src/tr.rs" 11 | 12 | [dependencies] 13 | bit-set = "0.5.0" 14 | fnv = "1.0.5" 15 | getopts = "0.2.18" 16 | uucore = "0.0.2" 17 | 18 | [[bin]] 19 | name = "tr" 20 | path = "../../common/uumain.rs" 21 | -------------------------------------------------------------------------------- /src/uu/uname/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uname" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_uname" 10 | path = "src/uname.rs" 11 | 12 | [dependencies] 13 | clap = "2.32.0" 14 | platform-info = "0.0.1" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "uname" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/unlink/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unlink" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_unlink" 10 | path = "src/unlink.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "unlink" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/expand/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "expand" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_expand" 10 | path = "src/expand.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | unicode-width = "0.1.5" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "expand" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/kill/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "kill" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_kill" 10 | path = "src/kill.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | uucore = { version = "0.0.2", features = ["signals"] } 15 | 16 | [[bin]] 17 | name = "kill" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/pathchk/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pathchk" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_pathchk" 10 | path = "src/pathchk.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "pathchk" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/true/src/true.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_true"] 2 | 3 | /* 4 | * This file is part of the uutils coreutils package. 5 | * 6 | * (c) Jordi Boggiano 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | pub fn uumain(_: Vec) -> i32 { 13 | 0 14 | } 15 | -------------------------------------------------------------------------------- /tests/fixtures/head/lorem_ipsum_default.expected: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, 2 | consectetur adipiscing elit. 3 | Nunc interdum suscipit sem vel ornare. 4 | Proin euismod, 5 | justo sed mollis dictum, 6 | eros urna ultricies augue, 7 | eu pharetra mi ex id ante. 8 | Duis convallis porttitor aliquam. 9 | Nunc vitae tincidunt ex. 10 | Suspendisse iaculis ligula ac diam consectetur lacinia. 11 | -------------------------------------------------------------------------------- /tests/fixtures/sort/month_default.txt: -------------------------------------------------------------------------------- 1 | Jan Lorem ipsum dolor sit amet 2 | Dec consectetur adipiscing elit 3 | May sed do eiusmod tempor incididunt 4 | Oct ut labore et dolore magna aliqua 5 | N/A Ut enim ad minim veniam, quis 6 | JUN nostrud exercitation ullamco 7 | mar laboris nisi ut aliquip ex ea 8 | Jul 2 these three lines 9 | Jul 1 should remain 2,1,3 10 | Jul 3 if --stable is provided 11 | -------------------------------------------------------------------------------- /tests/fixtures/sort/month_stable.txt: -------------------------------------------------------------------------------- 1 | Jan Lorem ipsum dolor sit amet 2 | Dec consectetur adipiscing elit 3 | May sed do eiusmod tempor incididunt 4 | Oct ut labore et dolore magna aliqua 5 | N/A Ut enim ad minim veniam, quis 6 | JUN nostrud exercitation ullamco 7 | mar laboris nisi ut aliquip ex ea 8 | Jul 2 these three lines 9 | Jul 1 should remain 2,1,3 10 | Jul 3 if --stable is provided 11 | -------------------------------------------------------------------------------- /tests/test_pathchk.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_default_mode() { 5 | // test the default mode 6 | 7 | // accept some reasonable default 8 | new_ucmd!().args(&["abc/def"]).succeeds().no_stdout(); 9 | 10 | // fail on long inputs 11 | new_ucmd!() 12 | .args(&[repeat_str("test", 20000)]) 13 | .fails() 14 | .no_stdout(); 15 | } 16 | -------------------------------------------------------------------------------- /src/uu/false/src/false.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_false"] 2 | 3 | /* 4 | * This file is part of the uutils coreutils package. 5 | * 6 | * (c) Jordi Boggiano 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | pub fn uumain(_: Vec) -> i32 { 13 | 1 14 | } 15 | -------------------------------------------------------------------------------- /src/uu/rm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rm" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_rm" 10 | path = "src/rm.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | walkdir = "2.2.8" 15 | remove_dir_all = "0.5.1" 16 | uucore = "0.0.2" 17 | 18 | [[bin]] 19 | name = "rm" 20 | path = "../../common/uumain.rs" 21 | -------------------------------------------------------------------------------- /src/uu/users/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "users" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_users" 10 | path = "src/users.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = { version = "0.0.2", features = ["utmpx"] } 15 | 16 | [[bin]] 17 | name = "users" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /tests/fixtures/sort/month_default.expected: -------------------------------------------------------------------------------- 1 | N/A Ut enim ad minim veniam, quis 2 | Jan Lorem ipsum dolor sit amet 3 | mar laboris nisi ut aliquip ex ea 4 | May sed do eiusmod tempor incididunt 5 | JUN nostrud exercitation ullamco 6 | Jul 1 should remain 2,1,3 7 | Jul 2 these three lines 8 | Jul 3 if --stable is provided 9 | Oct ut labore et dolore magna aliqua 10 | Dec consectetur adipiscing elit 11 | -------------------------------------------------------------------------------- /tests/fixtures/sort/month_stable.expected: -------------------------------------------------------------------------------- 1 | N/A Ut enim ad minim veniam, quis 2 | Jan Lorem ipsum dolor sit amet 3 | mar laboris nisi ut aliquip ex ea 4 | May sed do eiusmod tempor incididunt 5 | JUN nostrud exercitation ullamco 6 | Jul 2 these three lines 7 | Jul 1 should remain 2,1,3 8 | Jul 3 if --stable is provided 9 | Oct ut labore et dolore magna aliqua 10 | Dec consectetur adipiscing elit 11 | -------------------------------------------------------------------------------- /src/uu/chgrp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chgrp" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_chgrp" 10 | path = "src/chgrp.rs" 11 | 12 | [dependencies] 13 | uucore = { version = "0.0.2", features = ["entries", "fs"] } 14 | walkdir = "2.2.8" 15 | 16 | [[bin]] 17 | name = "chgrp" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/chroot/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chroot" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_chroot" 10 | path = "src/chroot.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = { version = "0.0.2", features = ["entries"] } 15 | 16 | [[bin]] 17 | name = "chroot" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/nproc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nproc" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_nproc" 10 | path = "src/nproc.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | num_cpus = "1.10" 16 | uucore = "0.0.2" 17 | 18 | [[bin]] 19 | name = "nproc" 20 | path = "../../common/uumain.rs" 21 | -------------------------------------------------------------------------------- /src/uu/relpath/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "relpath" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_relpath" 10 | path = "src/relpath.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = { version = "0.0.2", features = ["fs"] } 15 | 16 | [[bin]] 17 | name = "relpath" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/sleep/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sleep" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_sleep" 10 | path = "src/sleep.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = { version = "0.0.2", features = ["parse_time"] } 15 | 16 | [[bin]] 17 | name = "sleep" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /src/uu/tty/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tty" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_tty" 10 | path = "src/tty.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = { version = "0.0.2", features = ["fs"] } 16 | 17 | [[bin]] 18 | name = "tty" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/unexpand/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unexpand" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_unexpand" 10 | path = "src/unexpand.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | unicode-width = "0.1.5" 15 | uucore = "0.0.2" 16 | 17 | [[bin]] 18 | name = "unexpand" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/mktemp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mktemp" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_mktemp" 10 | path = "src/mktemp.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | rand = "0.5" 15 | tempfile = "2.1.5" 16 | uucore = "0.0.2" 17 | 18 | [[bin]] 19 | name = "mktemp" 20 | path = "../../common/uumain.rs" 21 | -------------------------------------------------------------------------------- /src/uu/realpath/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "realpath" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_realpath" 10 | path = "src/realpath.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = { version = "0.0.2", features = ["fs"] } 15 | 16 | [[bin]] 17 | name = "realpath" 18 | path = "../../common/uumain.rs" 19 | -------------------------------------------------------------------------------- /tests/fixtures/paste/html_colors.txt: -------------------------------------------------------------------------------- 1 | white 2 | #FFFFFF 3 | silver 4 | #C0C0C0 5 | gray 6 | #808080 7 | black 8 | #000000 9 | red 10 | #FF0000 11 | maroon 12 | #800000 13 | yellow 14 | #FFFF00 15 | olive 16 | #808000 17 | lime 18 | #00FF00 19 | green 20 | #008000 21 | aqua 22 | #00FFFF 23 | teal 24 | #008080 25 | blue 26 | #0000FF 27 | navy 28 | #000080 29 | fuchsia 30 | #FF00FF 31 | purple 32 | #800080 33 | -------------------------------------------------------------------------------- /src/uu/chmod/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chmod" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_chmod" 10 | path = "src/chmod.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | uucore = { version = "0.0.2", features = ["mode"] } 15 | walker = "1.0.0" 16 | 17 | [[bin]] 18 | name = "chmod" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/nohup/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nohup" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_nohup" 10 | path = "src/nohup.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = { version = "0.0.2", features = ["fs"] } 16 | 17 | [[bin]] 18 | name = "nohup" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/od/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "od" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_od" 10 | path = "src/od.rs" 11 | 12 | [dependencies] 13 | byteorder = "1.3.2" 14 | getopts = "0.2.18" 15 | half = "1.1.1" 16 | libc = "0.2.42" 17 | uucore = "0.0.2" 18 | 19 | [[bin]] 20 | name = "od" 21 | path = "../../common/uumain.rs" 22 | -------------------------------------------------------------------------------- /src/uu/stat/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "stat" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_stat" 10 | path = "src/stat.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | time = "0.1.40" 15 | uucore = { version = "0.0.2", features = ["entries"] } 16 | 17 | [[bin]] 18 | name = "stat" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /tests/fixtures/head/lorem_ipsum_verbose.expected: -------------------------------------------------------------------------------- 1 | ==> lorem_ipsum.txt <== 2 | Lorem ipsum dolor sit amet, 3 | consectetur adipiscing elit. 4 | Nunc interdum suscipit sem vel ornare. 5 | Proin euismod, 6 | justo sed mollis dictum, 7 | eros urna ultricies augue, 8 | eu pharetra mi ex id ante. 9 | Duis convallis porttitor aliquam. 10 | Nunc vitae tincidunt ex. 11 | Suspendisse iaculis ligula ac diam consectetur lacinia. 12 | -------------------------------------------------------------------------------- /src/uu/uptime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uptime" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_uptime" 10 | path = "src/uptime.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | time = "0.1.40" 15 | uucore = { version = "0.0.2", features = ["utmpx"] } 16 | 17 | [[bin]] 18 | name = "uptime" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/readlink/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "readlink" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_readlink" 10 | path = "src/readlink.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | uucore = { version = "0.0.2", features = ["fs"] } 16 | 17 | [[bin]] 18 | name = "readlink" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /tests/test_hostname.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_hostname() { 5 | let ls_default_res = new_ucmd!().succeeds(); 6 | let ls_short_res = new_ucmd!().arg("-s").succeeds(); 7 | let ls_domain_res = new_ucmd!().arg("-d").succeeds(); 8 | 9 | assert!(ls_default_res.stdout.len() >= ls_short_res.stdout.len()); 10 | assert!(ls_default_res.stdout.len() >= ls_domain_res.stdout.len()); 11 | } 12 | -------------------------------------------------------------------------------- /.cirrus.yml: -------------------------------------------------------------------------------- 1 | task: 2 | name: stable x86_64-unknown-freebsd-12 3 | freebsd_instance: 4 | image: freebsd-12-1-release-amd64 5 | setup_script: 6 | - pkg install -y curl gmake 7 | - curl https://sh.rustup.rs -sSf --output rustup.sh 8 | - sh rustup.sh -y --profile=minimal 9 | build_script: 10 | - . $HOME/.cargo/env 11 | - cargo build 12 | test_script: 13 | - . $HOME/.cargo/env 14 | - cargo test 15 | -------------------------------------------------------------------------------- /src/uu/who/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "who" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_who" 10 | path = "src/who.rs" 11 | 12 | [dependencies] 13 | uucore = { version = "0.0.2", features = ["utmpx"] } 14 | ## optional 15 | clippy = { version = "0.0.212", optional = true } 16 | 17 | [[bin]] 18 | name = "who" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/sort/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sort" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_sort" 10 | path = "src/sort.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | itertools = "0.8.0" 15 | semver = "0.9.0" 16 | uucore = { version = "0.0.2", features = ["fs"] } 17 | 18 | [[bin]] 19 | name = "sort" 20 | path = "../../common/uumain.rs" 21 | -------------------------------------------------------------------------------- /src/uu/test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "test" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_test" 10 | path = "src/test.rs" 11 | 12 | [dependencies] 13 | libc = "0.2.42" 14 | uucore = "0.0.2" 15 | 16 | [target.'cfg(target_os = "redox")'.dependencies] 17 | redox_syscall = "0.1" 18 | 19 | [[bin]] 20 | name = "test" 21 | path = "../../common/uumain.rs" 22 | -------------------------------------------------------------------------------- /tests/test_stdbuf.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_stdbuf_unbuffered_stdout() { 5 | if cfg!(target_os = "linux") { 6 | // This is a basic smoke test 7 | new_ucmd!() 8 | .args(&["-o0", "head"]) 9 | .pipe_in("The quick brown fox jumps over the lazy dog.") 10 | .run() 11 | .stdout_is("The quick brown fox jumps over the lazy dog."); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/test_tsort.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_sort_call_graph() { 5 | new_ucmd!() 6 | .arg("call_graph.txt") 7 | .run() 8 | .stdout_is_fixture("call_graph.expected"); 9 | } 10 | 11 | #[test] 12 | fn test_sort_self_loop() { 13 | new_ucmd!() 14 | .pipe_in("first first\nfirst second second second") 15 | .succeeds() 16 | .stdout_only("first\nsecond\n"); 17 | } 18 | -------------------------------------------------------------------------------- /src/uu/shred/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "shred" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_shred" 10 | path = "src/shred.rs" 11 | 12 | [dependencies] 13 | filetime = "0.2.1" 14 | getopts = "0.2.18" 15 | libc = "0.2.42" 16 | rand = "0.5" 17 | time = "0.1.40" 18 | uucore = "0.0.2" 19 | 20 | [[bin]] 21 | name = "shred" 22 | path = "../../common/uumain.rs" 23 | -------------------------------------------------------------------------------- /src/uu/touch/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "touch" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_touch" 10 | path = "src/touch.rs" 11 | 12 | [dependencies] 13 | filetime = "0.2.1" 14 | getopts = "0.2.18" 15 | time = "0.1.40" 16 | uucore = { version = "0.0.2", features = ["libc"] } 17 | 18 | [[bin]] 19 | name = "touch" 20 | path = "../../common/uumain.rs" 21 | -------------------------------------------------------------------------------- /src/uu/stdbuf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "stdbuf" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "build.rs" 7 | 8 | [lib] 9 | name = "uu_stdbuf" 10 | path = "src/stdbuf.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | tempdir = "0.3.7" 15 | uucore = "0.0.2" 16 | 17 | [build-dependencies] 18 | libstdbuf = { path="src/libstdbuf" } 19 | 20 | [[bin]] 21 | name = "stdbuf" 22 | path = "../../common/uumain.rs" 23 | -------------------------------------------------------------------------------- /src/uu/stdbuf/src/libstdbuf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "libstdbuf" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | 7 | [lib] 8 | name = "libstdbuf" 9 | path = "src/libstdbuf.rs" 10 | # XXX: the rlib is just to prevent Cargo from spitting out a warning 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [dependencies] 14 | cpp = "0.4" 15 | libc = "0.2" 16 | uucore = "0.0.2" 17 | 18 | [build-dependencies] 19 | cpp_build = "0.4" 20 | -------------------------------------------------------------------------------- /src/uu/base32/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "base32" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_base32" 10 | path = "src/base32.rs" 11 | 12 | [dependencies] 13 | uucore = { version = "0.0.2", features = ["encoding"] } 14 | ## optional 15 | clippy = { version = "0.0.212", optional = true } 16 | 17 | [[bin]] 18 | name = "base32" 19 | path = "../../common/uumain.rs" 20 | -------------------------------------------------------------------------------- /src/uu/cat/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cat" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_cat" 10 | path = "src/cat.rs" 11 | 12 | [dependencies] 13 | quick-error = "1.2.3" 14 | uucore = { version = "0.0.2", features = ["fs"] } 15 | 16 | [target.'cfg(unix)'.dependencies] 17 | unix_socket = "0.5.0" 18 | 19 | [[bin]] 20 | name = "cat" 21 | path = "../../common/uumain.rs" 22 | -------------------------------------------------------------------------------- /src/uu/timeout/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "timeout" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_timeout" 10 | path = "src/timeout.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = "0.2.42" 15 | time = "0.1.40" 16 | uucore = { version = "0.0.2", features = ["parse_time", "process"] } 17 | 18 | [[bin]] 19 | name = "timeout" 20 | path = "../../common/uumain.rs" 21 | -------------------------------------------------------------------------------- /tests/test_ls.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_ls_ls() { 5 | new_ucmd!().succeeds(); 6 | } 7 | 8 | #[test] 9 | fn test_ls_ls_i() { 10 | new_ucmd!().arg("-i").succeeds(); 11 | new_ucmd!().arg("-il").succeeds(); 12 | } 13 | 14 | #[test] 15 | fn test_ls_ls_color() { 16 | new_ucmd!().arg("--color").succeeds(); 17 | new_ucmd!().arg("--color=always").succeeds(); 18 | new_ucmd!().arg("--color=never").succeeds(); 19 | } 20 | -------------------------------------------------------------------------------- /src/uu/hostname/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hostname" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_hostname" 10 | path = "src/hostname.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2" 14 | libc = "0.2.42" 15 | uucore = "0.0.2" 16 | winapi = { version = "0.3", features = ["sysinfoapi", "winsock2"] } 17 | 18 | [[bin]] 19 | name = "hostname" 20 | path = "../../common/uumain.rs" 21 | -------------------------------------------------------------------------------- /src/uu/nl/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nl" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_nl" 10 | path = "src/nl.rs" 11 | 12 | [dependencies] 13 | aho-corasick = "0.7.3" 14 | getopts = "0.2.18" 15 | libc = "0.2.42" 16 | memchr = "2.2.0" 17 | regex = "1.0.1" 18 | regex-syntax = "0.6.7" 19 | uucore = "0.0.2" 20 | 21 | [[bin]] 22 | name = "nl" 23 | path = "../../common/uumain.rs" 24 | -------------------------------------------------------------------------------- /src/uu/install/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "install" 3 | version = "0.0.1" 4 | authors = ["Ben Eills "] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_install" 10 | path = "src/install.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | libc = ">= 0.2" 15 | uucore = "0.0.2" 16 | 17 | [dev-dependencies] 18 | time = "0.1.40" 19 | 20 | [[bin]] 21 | name = "install" 22 | path = "../../common/uumain.rs" 23 | -------------------------------------------------------------------------------- /src/uu/ptx/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ptx" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_ptx" 10 | path = "src/ptx.rs" 11 | 12 | [dependencies] 13 | aho-corasick = "0.7.3" 14 | getopts = "0.2.18" 15 | libc = "0.2.42" 16 | memchr = "2.2.0" 17 | regex = "1.0.1" 18 | regex-syntax = "0.6.7" 19 | uucore = "0.0.2" 20 | 21 | [[bin]] 22 | name = "ptx" 23 | path = "../../common/uumain.rs" 24 | -------------------------------------------------------------------------------- /src/uu/chown/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chown" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_chown" 10 | path = "src/chown.rs" 11 | 12 | [dependencies] 13 | glob = "0.3.0" 14 | uucore = { version = "0.0.2", features = ["entries", "fs"] } 15 | walkdir = "2.2" 16 | 17 | [dependencies.clippy] 18 | version = "0.0.212" 19 | optional = true 20 | 21 | [[bin]] 22 | name = "chown" 23 | path = "../../common/uumain.rs" 24 | -------------------------------------------------------------------------------- /src/uu/env/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "env" 3 | version = "0.0.1" 4 | authors = ["uutils developers"] 5 | description = "Set each NAME to VALUE in the environment and run COMMAND" 6 | license = "MIT" 7 | build = "../../common/mkmain.rs" 8 | edition = "2018" 9 | 10 | [lib] 11 | name = "uu_env" 12 | path = "src/env.rs" 13 | 14 | [dependencies] 15 | clap = "2.33" 16 | libc = "0.2.42" 17 | rust-ini = "0.13.0" 18 | uucore = "0.0.2" 19 | 20 | [[bin]] 21 | name = "env" 22 | path = "../../common/uumain.rs" 23 | -------------------------------------------------------------------------------- /src/uu/sync/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sync" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_sync" 10 | path = "src/sync.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | kernel32-sys = "0.2.2" 15 | libc = "0.2.42" 16 | uucore = { version = "0.0.2", features = ["wide"] } 17 | winapi = { version = "0.3", features = ["handleapi", "winerror"] } 18 | 19 | [[bin]] 20 | name = "sync" 21 | path = "../../common/uumain.rs" 22 | -------------------------------------------------------------------------------- /src/uu/tail/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tail" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_tail" 10 | path = "src/tail.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | kernel32-sys = "0.2.2" 15 | libc = "0.2.42" 16 | winapi = "0.3" 17 | uucore = "0.0.2" 18 | 19 | [target.'cfg(target_os = "redox")'.dependencies] 20 | redox_syscall = "0.1" 21 | 22 | [[bin]] 23 | name = "tail" 24 | path = "../../common/uumain.rs" 25 | -------------------------------------------------------------------------------- /src/uu/whoami/src/platform/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Jordi Boggiano 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #[cfg(unix)] 11 | pub use self::unix::getusername; 12 | 13 | #[cfg(windows)] 14 | pub use self::windows::getusername; 15 | 16 | #[cfg(unix)] 17 | mod unix; 18 | 19 | #[cfg(windows)] 20 | mod windows; 21 | -------------------------------------------------------------------------------- /src/uu/yes/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "yes" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | description = "Repeatedly output a line with all specified STRING(s), or 'y'." 7 | build = "../../common/mkmain.rs" 8 | 9 | [lib] 10 | name = "uu_yes" 11 | path = "src/yes.rs" 12 | 13 | [dependencies] 14 | clap = "2.32" 15 | uucore = { version = "0.0.2", features = ["zero-copy"] } 16 | 17 | [features] 18 | latency = [] 19 | default = [] 20 | 21 | [[bin]] 22 | name = "yes" 23 | path = "../../common/uumain.rs" 24 | -------------------------------------------------------------------------------- /src/uu/whoami/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "whoami" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | description = "Print effective user ID." 7 | build = "../../common/mkmain.rs" 8 | 9 | [lib] 10 | name = "uu_whoami" 11 | path = "src/whoami.rs" 12 | 13 | [dependencies] 14 | advapi32-sys = "0.2.0" 15 | clap = "2.32" 16 | uucore = { version = "0.0.2", features = ["entries", "wide"] } 17 | winapi = { version = "0.3", features = ["lmcons"] } 18 | 19 | [[bin]] 20 | name = "whoami" 21 | path = "../../common/uumain.rs" 22 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. uutils documentation master file, created by 2 | sphinx-quickstart on Tue Dec 5 23:20:18 2017. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to uutils's documentation! 7 | ================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :caption: Contents: 12 | 13 | arch 14 | uutils 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | -------------------------------------------------------------------------------- /src/uu/hashsum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hashsum" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_hashsum" 10 | path = "src/hashsum.rs" 11 | 12 | [dependencies] 13 | digest = "0.6.2" 14 | getopts = "0.2.18" 15 | hex = "0.2.0" 16 | libc = "0.2.42" 17 | md5 = "0.3.5" 18 | regex = "1.0.1" 19 | regex-syntax = "0.6.7" 20 | sha1 = "0.6.0" 21 | sha2 = "0.6.0" 22 | sha3 = "0.6.0" 23 | uucore = "0.0.2" 24 | 25 | [[bin]] 26 | name = "hashsum" 27 | path = "../../common/uumain.rs" 28 | -------------------------------------------------------------------------------- /src/uu/more/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "more" 3 | version = "0.0.1" 4 | authors = [] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_more" 10 | path = "src/more.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | uucore = "0.0.2" 15 | 16 | [target.'cfg(target_os = "redox")'.dependencies] 17 | redox_termios = "0.1" 18 | redox_syscall = "0.1" 19 | 20 | [target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies] 21 | nix = "0.8.1" 22 | 23 | [[bin]] 24 | name = "more" 25 | path = "../../common/uumain.rs" 26 | -------------------------------------------------------------------------------- /src/uu/whoami/src/platform/unix.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Jordi Boggiano 5 | * (c) Jian Zeng 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | use std::io::Result; 12 | use uucore::entries::uid2usr; 13 | use uucore::libc::geteuid; 14 | 15 | pub unsafe fn getusername() -> Result { 16 | // Get effective user id 17 | let uid = geteuid(); 18 | uid2usr(uid) 19 | } 20 | -------------------------------------------------------------------------------- /tests/fixtures/tsort/call_graph.txt: -------------------------------------------------------------------------------- 1 | main parse_options 2 | main tail_file 3 | main tail_forever 4 | tail_file pretty_name 5 | tail_file write_header 6 | tail_file tail 7 | tail_forever recheck 8 | tail_forever pretty_name 9 | tail_forever write_header 10 | tail_forever dump_remainder 11 | tail tail_lines 12 | tail tail_bytes 13 | tail_lines start_lines 14 | tail_lines dump_remainder 15 | tail_lines file_lines 16 | tail_lines pipe_lines 17 | tail_bytes xlseek 18 | tail_bytes start_bytes 19 | tail_bytes dump_remainder 20 | tail_bytes pipe_bytes 21 | file_lines dump_remainder 22 | recheck pretty_name 23 | -------------------------------------------------------------------------------- /src/uu/ls/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ls" 3 | version = "0.0.1" 4 | authors = ["Jeremiah Peschka "] 5 | license = "MIT" 6 | build = "../../common/mkmain.rs" 7 | 8 | [lib] 9 | name = "uu_ls" 10 | path = "src/ls.rs" 11 | 12 | [dependencies] 13 | getopts = "0.2.18" 14 | isatty = "0.1" 15 | lazy_static = "1.0.1" 16 | number_prefix = "0.2.8" 17 | term_grid = "0.1.5" 18 | termsize = "0.1.6" 19 | time = "0.1.40" 20 | unicode-width = "0.1.5" 21 | uucore = { version = "0.0.2", features = ["entries", "fs"] } 22 | 23 | [[bin]] 24 | name = "ls" 25 | path = "../../common/uumain.rs" 26 | -------------------------------------------------------------------------------- /docs/uutils.rst: -------------------------------------------------------------------------------- 1 | .. run core utilities 2 | 3 | ====== 4 | uutils 5 | ====== 6 | 7 | .. FIXME: this needs to be autogenerated somehow 8 | 9 | -------- 10 | Synopsis 11 | -------- 12 | 13 | ``uutils`` [OPTION]... [PROGRAM] [OPTION]... [ARGUMENTS]... 14 | 15 | ----------- 16 | Description 17 | ----------- 18 | 19 | ``uutils`` is a program that contains that other coreutils commands, somewhat 20 | similar to Busybox. 21 | 22 | --help, -h print a help menu for PROGRAM displaying accepted options and 23 | arguments; if PROGRAM was not given, do the same but for this 24 | program 25 | -------------------------------------------------------------------------------- /util/rewrite_rules.rs: -------------------------------------------------------------------------------- 1 | //! Rules to update the codebase using Rerast 2 | 3 | /// Converts try!() to ? 4 | fn try_to_question_mark>(r: Result) -> Result { 5 | replace!(try!(r) => r?); 6 | unreachable!() 7 | } 8 | 9 | fn trim_left_to_start(s: &str) { 10 | replace!(s.trim_left() => s.trim_start()); 11 | replace!(s.trim_right() => s.trim_end()); 12 | } 13 | 14 | fn trim_left_matches_to_start bool>(s: &str, inner: P) { 15 | replace!(s.trim_left_matches(inner) => s.trim_start_matches(inner)); 16 | replace!(s.trim_right_matches(inner) => s.trim_end_matches(inner)); 17 | } 18 | -------------------------------------------------------------------------------- /tests/test_cksum.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_single_file() { 5 | new_ucmd!() 6 | .arg("lorem_ipsum.txt") 7 | .succeeds() 8 | .stdout_is_fixture("single_file.expected"); 9 | } 10 | 11 | #[test] 12 | fn test_multiple_files() { 13 | new_ucmd!() 14 | .arg("lorem_ipsum.txt") 15 | .arg("alice_in_wonderland.txt") 16 | .succeeds() 17 | .stdout_is_fixture("multiple_files.expected"); 18 | } 19 | 20 | #[test] 21 | fn test_stdin() { 22 | new_ucmd!() 23 | .pipe_in_fixture("lorem_ipsum.txt") 24 | .succeeds() 25 | .stdout_is_fixture("stdin.expected"); 26 | } 27 | -------------------------------------------------------------------------------- /src/uu/tail/src/platform/redox.rs: -------------------------------------------------------------------------------- 1 | extern crate syscall; 2 | 3 | use self::syscall::{Error, ENOSYS, EPERM}; 4 | 5 | pub type Pid = usize; 6 | 7 | pub struct ProcessChecker { 8 | pid: self::Pid, 9 | } 10 | 11 | impl ProcessChecker { 12 | pub fn new(process_id: self::Pid) -> ProcessChecker { 13 | ProcessChecker { pid: process_id } 14 | } 15 | 16 | // Borrowing mutably to be aligned with Windows implementation 17 | pub fn is_dead(&mut self) -> bool { 18 | let res = syscall::kill(self.pid, 0); 19 | res != Ok(0) && res != Err(Error::new(EPERM)) 20 | } 21 | } 22 | 23 | pub fn supports_pid_checks(pid: self::Pid) -> bool { 24 | true 25 | } 26 | -------------------------------------------------------------------------------- /docs/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = uutils 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help GNUmakefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: GNUmakefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /tests/test_fold.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_default_80_column_wrap() { 5 | new_ucmd!() 6 | .arg("lorem_ipsum.txt") 7 | .run() 8 | .stdout_is_fixture("lorem_ipsum_80_column.expected"); 9 | } 10 | 11 | #[test] 12 | fn test_40_column_hard_cutoff() { 13 | new_ucmd!() 14 | .args(&["-w", "40", "lorem_ipsum.txt"]) 15 | .run() 16 | .stdout_is_fixture("lorem_ipsum_40_column_hard.expected"); 17 | } 18 | 19 | #[test] 20 | fn test_40_column_word_boundary() { 21 | new_ucmd!() 22 | .args(&["-s", "-w", "40", "lorem_ipsum.txt"]) 23 | .run() 24 | .stdout_is_fixture("lorem_ipsum_40_column_word.expected"); 25 | } 26 | -------------------------------------------------------------------------------- /tests/test_test.rs: -------------------------------------------------------------------------------- 1 | // 2 | // This file is part of the uutils coreutils package. 3 | // 4 | // (c) mahkoh (ju.orth [at] gmail [dot] com) 5 | // 6 | // For the full copyright and license information, please view the LICENSE 7 | // file that was distributed with this source code. 8 | // 9 | 10 | use common::util::*; 11 | 12 | #[test] 13 | fn test_op_prec_and_or_1() { 14 | new_ucmd!().args(&[" ", "-o", "", "-a", ""]).succeeds(); 15 | } 16 | 17 | #[test] 18 | fn test_op_prec_and_or_2() { 19 | new_ucmd!() 20 | .args(&["", "-a", "", "-o", " ", "-a", " "]) 21 | .succeeds(); 22 | } 23 | 24 | #[test] 25 | fn test_or_as_filename() { 26 | new_ucmd!().args(&["x", "-a", "-z", "-o"]).fails(); 27 | } 28 | -------------------------------------------------------------------------------- /src/uu/tail/src/platform/mod.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Alexander Batischev 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #[cfg(unix)] 11 | pub use self::unix::{supports_pid_checks, Pid, ProcessChecker}; 12 | 13 | #[cfg(windows)] 14 | pub use self::windows::{supports_pid_checks, Pid, ProcessChecker}; 15 | 16 | #[cfg(target_os = "redox")] 17 | pub use self::redox::{supports_pid_checks, Pid, ProcessChecker}; 18 | 19 | #[cfg(unix)] 20 | mod unix; 21 | 22 | #[cfg(windows)] 23 | mod windows; 24 | 25 | #[cfg(target_os = "redox")] 26 | mod redox; 27 | -------------------------------------------------------------------------------- /docs/arch.rst: -------------------------------------------------------------------------------- 1 | .. print machine hardware name 2 | 3 | ==== 4 | arch 5 | ==== 6 | 7 | .. FIXME: this needs to be autogenerated somehow 8 | 9 | -------- 10 | Synopsis 11 | -------- 12 | 13 | ``arch`` [OPTION]... 14 | 15 | ----------- 16 | Description 17 | ----------- 18 | 19 | ``arch`` is an alias for ``uname -m``. They both print the machine hardware 20 | name. 21 | 22 | An exit code of zero indicates success, whereas anything else means failure. 23 | For this program, a non-zero exit code generally means the user provided 24 | invalid options. 25 | 26 | -h, --help print a help menu for this program displaying accepted 27 | options and arguments 28 | -v, --version print the version number of this program 29 | -------------------------------------------------------------------------------- /tests/test_seq.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_count_up() { 5 | new_ucmd!() 6 | .args(&["10"]) 7 | .run() 8 | .stdout_is("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"); 9 | } 10 | 11 | #[test] 12 | fn test_count_down() { 13 | new_ucmd!() 14 | .args(&["--", "5", "-1", "1"]) 15 | .run() 16 | .stdout_is("5\n4\n3\n2\n1\n"); 17 | } 18 | 19 | #[test] 20 | fn test_separator_and_terminator() { 21 | new_ucmd!() 22 | .args(&["-s", ",", "-t", "!", "2", "6"]) 23 | .run() 24 | .stdout_is("2,3,4,5,6!"); 25 | } 26 | 27 | #[test] 28 | fn test_equalize_widths() { 29 | new_ucmd!() 30 | .args(&["-w", "5", "10"]) 31 | .run() 32 | .stdout_is("05\n06\n07\n08\n09\n10\n"); 33 | } 34 | -------------------------------------------------------------------------------- /tests/fixtures/fold/lorem_ipsum.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum suscipit sem vel ornare. Proin euismod, justo sed mollis dictum, eros urna ultricies augue, eu pharetra mi ex id ante. Duis convallis porttitor aliquam. Nunc vitae tincidunt ex. Suspendisse iaculis ligula ac diam consectetur lacinia. Donec vel velit dui. Etiam fringilla, dolor quis tempor vehicula, lacus turpis bibendum velit, et pellentesque elit odio a magna. Cras vulputate tortor non libero vehicula euismod. Aliquam tincidunt nisl eget enim cursus, viverra sagittis magna commodo. Cras rhoncus egestas leo nec blandit. Suspendisse potenti. Etiam ullamcorper leo vel lacus vestibulum, cursus semper eros efficitur. In hac habitasse platea dictumst. Phasellus scelerisque vehicula fringilla. 2 | -------------------------------------------------------------------------------- /src/uu/tail/README.md: -------------------------------------------------------------------------------- 1 | Rudimentary tail implementation. 2 | 3 | ## Missing features: 4 | 5 | ### Flags with features 6 | * `--max-unchanged-stats` : with `--follow=name`, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files). With inotify, this option is rarely useful. 7 | * `--retry` : keep trying to open a file even when it is or becomes inaccessible; useful when follow‐ing by name, i.e., with `--follow=name` 8 | 9 | ### Others 10 | The current implementation does not handle `-` as an alias for stdin. 11 | 12 | ## Possible optimizations: 13 | * Don't read the whole file if not using `-f` and input is regular file. Read in chunks from the end going backwards, reading each individual chunk forward. 14 | -------------------------------------------------------------------------------- /tests/test_dirname.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_path_with_trailing_slashes() { 5 | new_ucmd!() 6 | .arg("/root/alpha/beta/gamma/delta/epsilon/omega//") 7 | .run() 8 | .stdout_is("/root/alpha/beta/gamma/delta/epsilon\n"); 9 | } 10 | 11 | #[test] 12 | fn test_path_without_trailing_slashes() { 13 | new_ucmd!() 14 | .arg("/root/alpha/beta/gamma/delta/epsilon/omega") 15 | .run() 16 | .stdout_is("/root/alpha/beta/gamma/delta/epsilon\n"); 17 | } 18 | 19 | #[test] 20 | fn test_root() { 21 | new_ucmd!().arg("/").run().stdout_is("/\n"); 22 | } 23 | 24 | #[test] 25 | fn test_pwd() { 26 | new_ucmd!().arg(".").run().stdout_is(".\n"); 27 | } 28 | 29 | #[test] 30 | fn test_empty() { 31 | new_ucmd!().arg("").run().stdout_is(".\n"); 32 | } 33 | -------------------------------------------------------------------------------- /tests/fixtures/ptx/gnu_ext_disabled_roff_input_ref.expected: -------------------------------------------------------------------------------- 1 | .xx "" "some other like" "%a, b#, c$c" "" "and" 2 | .xx "" "" "also~or^" "" "maybe" 3 | .xx "" "" "and back\slash" "" "oh," 4 | .xx "" "some other like %a," "b#, c$c" "" "and" 5 | .xx "" "and" "back\slash" "" "oh," 6 | .xx "" "some other like %a, b#," "c$c" "" "and" 7 | .xx "" "check special" "characters:" "" "let's" 8 | .xx "" "" "check special characters:" "" "let's" 9 | .xx "" "" "for roff" "" """quotes""," 10 | .xx "" "" "for tex" "" "{brackets}" 11 | .xx "" "some other" "like %a, b#, c$c" "" "and" 12 | .xx "" "some" "other like %a, b#, c$c" "" "and" 13 | .xx "" "for" "roff" "" """quotes""," 14 | .xx "" "" "some other like %a, b#, c$c" "" "and" 15 | .xx "" "check" "special characters:" "" "let's" 16 | .xx "" "for" "tex" "" "{brackets}" 17 | .xx "" "" "world!" "" "hello" 18 | -------------------------------------------------------------------------------- /tests/fixtures/ptx/gnu_ext_disabled_tex_input_ref.expected: -------------------------------------------------------------------------------- 1 | \xx {}{some other like}{\%a,}{ b\#, c\$c}{}{and} 2 | \xx {}{}{also~or^}{}{}{maybe} 3 | \xx {}{}{and}{ back\backslash{}slash}{}{oh,} 4 | \xx {}{some other like \%a,}{b\#,}{ c\$c}{}{and} 5 | \xx {}{and}{back\backslash{}slash}{}{}{oh,} 6 | \xx {}{some other like \%a, b\#,}{c\$c}{}{}{and} 7 | \xx {}{check special}{characters:}{}{}{let's} 8 | \xx {}{}{check}{ special characters:}{}{let's} 9 | \xx {}{}{for}{ roff}{}{"quotes",} 10 | \xx {}{}{for}{ tex}{}{$\{$brackets$\}$} 11 | \xx {}{some other}{like}{ \%a, b\#, c\$c}{}{and} 12 | \xx {}{some}{other}{ like \%a, b\#, c\$c}{}{and} 13 | \xx {}{for}{roff}{}{}{"quotes",} 14 | \xx {}{}{some}{ other like \%a, b\#, c\$c}{}{and} 15 | \xx {}{check}{special}{ characters:}{}{let's} 16 | \xx {}{for}{tex}{}{}{$\{$brackets$\}$} 17 | \xx {}{}{world!}{}{}{hello} 18 | -------------------------------------------------------------------------------- /tests/fixtures/sum/lorem_ipsum.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing 2 | elit. Nunc interdum suscipit sem vel ornare. Proin euismod, justo 3 | sed mollis dictum, eros urna ultricies augue, eu pharetra mi ex id 4 | ante. Duis convallis porttitor aliquam. Nunc vitae tincidunt ex. 5 | Suspendisse iaculis ligula ac diam consectetur lacinia. Donec vel 6 | velit dui. Etiam fringilla, dolor quis tempor vehicula, lacus 7 | turpis bibendum velit, et pellentesque elit odio a magna. Cras 8 | vulputate tortor non libero vehicula euismod. Aliquam tincidunt 9 | nisl eget enim cursus, viverra sagittis magna commodo. Cras rhoncus 10 | egestas leo nec blandit. Suspendisse potenti. Etiam ullamcorper 11 | leo vel lacus vestibulum, cursus semper eros efficitur. In hac 12 | habitasse platea dictumst. Phasellus scelerisque vehicula 13 | fringilla. 14 | -------------------------------------------------------------------------------- /tests/fixtures/wc/lorem_ipsum.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing 2 | elit. Nunc interdum suscipit sem vel ornare. Proin euismod, justo 3 | sed mollis dictum, eros urna ultricies augue, eu pharetra mi ex id 4 | ante. Duis convallis porttitor aliquam. Nunc vitae tincidunt ex. 5 | Suspendisse iaculis ligula ac diam consectetur lacinia. Donec vel 6 | velit dui. Etiam fringilla, dolor quis tempor vehicula, lacus 7 | turpis bibendum velit, et pellentesque elit odio a magna. Cras 8 | vulputate tortor non libero vehicula euismod. Aliquam tincidunt 9 | nisl eget enim cursus, viverra sagittis magna commodo. Cras rhoncus 10 | egestas leo nec blandit. Suspendisse potenti. Etiam ullamcorper 11 | leo vel lacus vestibulum, cursus semper eros efficitur. In hac 12 | habitasse platea dictumst. Phasellus scelerisque vehicula 13 | fringilla. 14 | -------------------------------------------------------------------------------- /src/uu/cp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cp" 3 | version = "0.0.1" 4 | authors = [ 5 | "Jordy Dickinson ", 6 | "Joshua S. Miller ", 7 | ] 8 | license = "MIT" 9 | build = "../../common/mkmain.rs" 10 | 11 | [lib] 12 | name = "uu_cp" 13 | path = "src/cp.rs" 14 | 15 | [dependencies] 16 | clap = "2.32.0" 17 | filetime = "0.2" 18 | getopts = "0.2.18" 19 | libc = "0.2.42" 20 | quick-error = "1.2.3" 21 | uucore = { version = "0.0.2", features = ["fs"] } 22 | walkdir = "2.2.8" 23 | 24 | [target.'cfg(target_os = "linux")'.dependencies] 25 | ioctl-sys = "0.5.2" 26 | 27 | [target.'cfg(target_os = "windows")'.dependencies] 28 | kernel32-sys = "0.2.2" 29 | winapi = "0.3" 30 | 31 | [target.'cfg(unix)'.dependencies] 32 | xattr="0.2.1" 33 | 34 | [[bin]] 35 | name = "cp" 36 | path = "../../common/uumain.rs" 37 | -------------------------------------------------------------------------------- /tests/fixtures/cksum/lorem_ipsum.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing 2 | elit. Nunc interdum suscipit sem vel ornare. Proin euismod, justo 3 | sed mollis dictum, eros urna ultricies augue, eu pharetra mi ex id 4 | ante. Duis convallis porttitor aliquam. Nunc vitae tincidunt ex. 5 | Suspendisse iaculis ligula ac diam consectetur lacinia. Donec vel 6 | velit dui. Etiam fringilla, dolor quis tempor vehicula, lacus 7 | turpis bibendum velit, et pellentesque elit odio a magna. Cras 8 | vulputate tortor non libero vehicula euismod. Aliquam tincidunt 9 | nisl eget enim cursus, viverra sagittis magna commodo. Cras rhoncus 10 | egestas leo nec blandit. Suspendisse potenti. Etiam ullamcorper 11 | leo vel lacus vestibulum, cursus semper eros efficitur. In hac 12 | habitasse platea dictumst. Phasellus scelerisque vehicula 13 | fringilla. 14 | -------------------------------------------------------------------------------- /tests/fixtures/fold/lorem_ipsum_80_column.expected: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc interdum suscipit 2 | sem vel ornare. Proin euismod, justo sed mollis dictum, eros urna ultricies augu 3 | e, eu pharetra mi ex id ante. Duis convallis porttitor aliquam. Nunc vitae tinci 4 | dunt ex. Suspendisse iaculis ligula ac diam consectetur lacinia. Donec vel velit 5 | dui. Etiam fringilla, dolor quis tempor vehicula, lacus turpis bibendum velit, 6 | et pellentesque elit odio a magna. Cras vulputate tortor non libero vehicula eui 7 | smod. Aliquam tincidunt nisl eget enim cursus, viverra sagittis magna commodo. C 8 | ras rhoncus egestas leo nec blandit. Suspendisse potenti. Etiam ullamcorper leo 9 | vel lacus vestibulum, cursus semper eros efficitur. In hac habitasse platea dict 10 | umst. Phasellus scelerisque vehicula fringilla. 11 | -------------------------------------------------------------------------------- /src/uu/arch/src/arch.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_arch"] 2 | 3 | // This file is part of the uutils coreutils package. 4 | // 5 | // (c) Smigle00 6 | // (c) Jian Zeng 7 | // 8 | // For the full copyright and license information, please view the LICENSE 9 | // file that was distributed with this source code. 10 | // 11 | 12 | extern crate platform_info; 13 | #[macro_use] 14 | extern crate uucore; 15 | 16 | use platform_info::*; 17 | 18 | static SYNTAX: &str = ""; 19 | static SUMMARY: &str = "Determine architecture name for current machine."; 20 | static LONG_HELP: &str = ""; 21 | 22 | pub fn uumain(args: Vec) -> i32 { 23 | new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); 24 | let uts = return_if_err!(1, PlatformInfo::new()); 25 | println!("{}", uts.machine().trim()); 26 | 0 27 | } 28 | -------------------------------------------------------------------------------- /src/uu/cp/README.md: -------------------------------------------------------------------------------- 1 | ## Feature list 2 | 3 | ### To Do 4 | 5 | - [ ] archive 6 | - [ ] attributes-only 7 | - [ ] copy-contents 8 | - [ ] no-dereference-preserve-linkgs 9 | - [ ] dereference 10 | - [ ] no-dereference 11 | - [ ] preserve-default-attributes 12 | - [ ] preserve 13 | - [ ] no-preserve 14 | - [ ] parents 15 | - [ ] reflink 16 | - [ ] sparse 17 | - [ ] strip-trailing-slashes 18 | - [ ] update 19 | - [ ] one-file-system 20 | - [ ] context 21 | - [ ] cli-symbolic-links 22 | 23 | ### Completed 24 | 25 | - [x] backup 26 | - [x] force (Not implemented on Windows) 27 | - [x] interactive 28 | - [x] link 29 | - [x] no-clobber 30 | - [x] no-target-directory 31 | - [x] paths 32 | - [x] recursive 33 | - [x] remove-destination (On Windows, current only works for writeable files) 34 | - [x] suffix 35 | - [x] symbolic-link 36 | - [x] target-directory 37 | - [x] verbose 38 | - [x] version 39 | -------------------------------------------------------------------------------- /tests/test_truncate.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | use std::io::{Seek, SeekFrom, Write}; 3 | 4 | static TFILE1: &'static str = "truncate_test_1"; 5 | static TFILE2: &'static str = "truncate_test_2"; 6 | 7 | #[test] 8 | fn test_increase_file_size() { 9 | let (at, mut ucmd) = at_and_ucmd!(); 10 | let mut file = at.make_file(TFILE1); 11 | ucmd.args(&["-s", "+5K", TFILE1]).succeeds(); 12 | 13 | file.seek(SeekFrom::End(0)).unwrap(); 14 | assert!(file.seek(SeekFrom::Current(0)).unwrap() == 5 * 1024); 15 | } 16 | 17 | #[test] 18 | fn test_decrease_file_size() { 19 | let (at, mut ucmd) = at_and_ucmd!(); 20 | let mut file = at.make_file(TFILE2); 21 | file.write_all(b"1234567890").unwrap(); 22 | ucmd.args(&["--size=-4", TFILE2]).succeeds(); 23 | file.seek(SeekFrom::End(0)).unwrap(); 24 | assert!(file.seek(SeekFrom::Current(0)).unwrap() == 6); 25 | } 26 | -------------------------------------------------------------------------------- /src/uu/printf/src/tokenize/num_format/format_field.rs: -------------------------------------------------------------------------------- 1 | //! Primitievs used by Sub Tokenizer 2 | //! and num_format modules 3 | #[derive(Clone)] 4 | pub enum FieldType { 5 | Strf, 6 | Floatf, 7 | CninetyNineHexFloatf, 8 | Scif, 9 | Decf, 10 | Intf, 11 | Charf, 12 | } 13 | 14 | // #[allow(non_camel_case_types)] 15 | // pub enum FChar { 16 | // d, 17 | // e, 18 | // E, 19 | // i, 20 | // f, 21 | // F, 22 | // g, 23 | // G, 24 | // u, 25 | // x, 26 | // X, 27 | // o 28 | // } 29 | // 30 | 31 | // a Sub Tokens' fields are stored 32 | // as a single object so they can be more simply 33 | // passed by ref to num_format in a Sub method 34 | #[derive(Clone)] 35 | pub struct FormatField<'a> { 36 | pub min_width: Option, 37 | pub second_field: Option, 38 | pub field_char: &'a char, 39 | pub field_type: &'a FieldType, 40 | pub orig: &'a String, 41 | } 42 | -------------------------------------------------------------------------------- /tests/fixtures/head/lorem_ipsum.txt: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, 2 | consectetur adipiscing elit. 3 | Nunc interdum suscipit sem vel ornare. 4 | Proin euismod, 5 | justo sed mollis dictum, 6 | eros urna ultricies augue, 7 | eu pharetra mi ex id ante. 8 | Duis convallis porttitor aliquam. 9 | Nunc vitae tincidunt ex. 10 | Suspendisse iaculis ligula ac diam consectetur lacinia. 11 | Donec vel velit dui. 12 | Etiam fringilla, 13 | dolor quis tempor vehicula, 14 | lacus turpis bibendum velit, 15 | et pellentesque elit odio a magna. 16 | Cras vulputate tortor non libero vehicula euismod. 17 | Aliquam tincidunt nisl eget enim cursus, 18 | viverra sagittis magna commodo. 19 | Cras rhoncus egestas leo nec blandit. 20 | Suspendisse potenti. 21 | Etiam ullamcorper leo vel lacus vestibulum, 22 | cursus semper eros efficitur. 23 | In hac habitasse platea dictumst. 24 | Phasellus scelerisque vehicula fringilla. 25 | -------------------------------------------------------------------------------- /tests/fixtures/fold/lorem_ipsum_40_column_hard.expected: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur 2 | adipiscing elit. Nunc interdum suscipit 3 | sem vel ornare. Proin euismod, justo sed 4 | mollis dictum, eros urna ultricies augu 5 | e, eu pharetra mi ex id ante. Duis conva 6 | llis porttitor aliquam. Nunc vitae tinci 7 | dunt ex. Suspendisse iaculis ligula ac d 8 | iam consectetur lacinia. Donec vel velit 9 | dui. Etiam fringilla, dolor quis tempor 10 | vehicula, lacus turpis bibendum velit, 11 | et pellentesque elit odio a magna. Cras 12 | vulputate tortor non libero vehicula eui 13 | smod. Aliquam tincidunt nisl eget enim c 14 | ursus, viverra sagittis magna commodo. C 15 | ras rhoncus egestas leo nec blandit. Sus 16 | pendisse potenti. Etiam ullamcorper leo 17 | vel lacus vestibulum, cursus semper eros 18 | efficitur. In hac habitasse platea dict 19 | umst. Phasellus scelerisque vehicula fri 20 | ngilla. 21 | -------------------------------------------------------------------------------- /tests/fixtures/sort/default_unsorted_ints.txt: -------------------------------------------------------------------------------- 1 | 33 2 | 16 3 | 35 4 | 56 5 | 72 6 | 37 7 | 21 8 | 49 9 | 70 10 | 48 11 | 90 12 | 83 13 | 44 14 | 79 15 | 10 16 | 20 17 | 4 18 | 26 19 | 27 20 | 63 21 | 29 22 | 47 23 | 51 24 | 85 25 | 88 26 | 46 27 | 30 28 | 61 29 | 93 30 | 81 31 | 78 32 | 53 33 | 87 34 | 18 35 | 98 36 | 38 37 | 13 38 | 39 39 | 23 40 | 71 41 | 5 42 | 100 43 | 96 44 | 8 45 | 24 46 | 14 47 | 28 48 | 15 49 | 25 50 | 43 51 | 36 52 | 67 53 | 75 54 | 66 55 | 31 56 | 57 57 | 34 58 | 80 59 | 40 60 | 86 61 | 17 62 | 55 63 | 9 64 | 1 65 | 62 66 | 12 67 | 74 68 | 58 69 | 69 70 | 76 71 | 11 72 | 73 73 | 68 74 | 59 75 | 41 76 | 45 77 | 52 78 | 97 79 | 82 80 | 6 81 | 7 82 | 77 83 | 42 84 | 84 85 | 95 86 | 94 87 | 89 88 | 19 89 | 64 90 | 2 91 | 22 92 | 50 93 | 60 94 | 32 95 | 92 96 | 3 97 | 99 98 | 65 99 | 54 100 | 91 101 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_unsorted_ints.txt: -------------------------------------------------------------------------------- 1 | 33 2 | 16 3 | 35 4 | 56 5 | 72 6 | 37 7 | 21 8 | 49 9 | 70 10 | 48 11 | 90 12 | 83 13 | 44 14 | 79 15 | 10 16 | 20 17 | 4 18 | 26 19 | 27 20 | 63 21 | 29 22 | 47 23 | 51 24 | 85 25 | 88 26 | 46 27 | 30 28 | 61 29 | 93 30 | 81 31 | 78 32 | 53 33 | 87 34 | 18 35 | 98 36 | 38 37 | 13 38 | 39 39 | 23 40 | 71 41 | 5 42 | 100 43 | 96 44 | 8 45 | 24 46 | 14 47 | 28 48 | 15 49 | 25 50 | 43 51 | 36 52 | 67 53 | 75 54 | 66 55 | 31 56 | 57 57 | 34 58 | 80 59 | 40 60 | 86 61 | 17 62 | 55 63 | 9 64 | 1 65 | 62 66 | 12 67 | 74 68 | 58 69 | 69 70 | 76 71 | 11 72 | 73 73 | 68 74 | 59 75 | 41 76 | 45 77 | 52 78 | 97 79 | 82 80 | 6 81 | 7 82 | 77 83 | 42 84 | 84 85 | 95 86 | 94 87 | 89 88 | 19 89 | 64 90 | 2 91 | 22 92 | 50 93 | 60 94 | 32 95 | 92 96 | 3 97 | 99 98 | 65 99 | 54 100 | 91 101 | -------------------------------------------------------------------------------- /src/uu/printf/src/cli.rs: -------------------------------------------------------------------------------- 1 | //! stdio convenience fns 2 | 3 | use std::env; 4 | use std::io::{stderr, stdout, Write}; 5 | 6 | pub const EXIT_OK: i32 = 0; 7 | pub const EXIT_ERR: i32 = 1; 8 | 9 | pub fn err_msg(msg: &str) { 10 | let exe_path = match env::current_exe() { 11 | Ok(p) => p.to_string_lossy().into_owned(), 12 | _ => String::from(""), 13 | }; 14 | writeln!(&mut stderr(), "{}: {}", exe_path, msg).unwrap(); 15 | } 16 | 17 | // by default stdout only flushes 18 | // to console when a newline is passed. 19 | #[allow(unused_must_use)] 20 | pub fn flush_char(c: char) { 21 | print!("{}", c); 22 | stdout().flush(); 23 | } 24 | #[allow(unused_must_use)] 25 | pub fn flush_str(s: &str) { 26 | print!("{}", s); 27 | stdout().flush(); 28 | } 29 | #[allow(unused_must_use)] 30 | pub fn flush_bytes(bslice: &[u8]) { 31 | stdout().write(bslice); 32 | stdout().flush(); 33 | } 34 | -------------------------------------------------------------------------------- /tests/fixtures/sort/default_unsorted_ints.expected: -------------------------------------------------------------------------------- 1 | 1 2 | 10 3 | 100 4 | 11 5 | 12 6 | 13 7 | 14 8 | 15 9 | 16 10 | 17 11 | 18 12 | 19 13 | 2 14 | 20 15 | 21 16 | 22 17 | 23 18 | 24 19 | 25 20 | 26 21 | 27 22 | 28 23 | 29 24 | 3 25 | 30 26 | 31 27 | 32 28 | 33 29 | 34 30 | 35 31 | 36 32 | 37 33 | 38 34 | 39 35 | 4 36 | 40 37 | 41 38 | 42 39 | 43 40 | 44 41 | 45 42 | 46 43 | 47 44 | 48 45 | 49 46 | 5 47 | 50 48 | 51 49 | 52 50 | 53 51 | 54 52 | 55 53 | 56 54 | 57 55 | 58 56 | 59 57 | 6 58 | 60 59 | 61 60 | 62 61 | 63 62 | 64 63 | 65 64 | 66 65 | 67 66 | 68 67 | 69 68 | 7 69 | 70 70 | 71 71 | 72 72 | 73 73 | 74 74 | 75 75 | 76 76 | 77 77 | 78 78 | 79 79 | 8 80 | 80 81 | 81 82 | 82 83 | 83 84 | 84 85 | 85 86 | 86 87 | 87 88 | 88 89 | 89 90 | 9 91 | 90 92 | 91 93 | 92 94 | 93 95 | 94 96 | 95 97 | 96 98 | 97 99 | 98 100 | 99 101 | -------------------------------------------------------------------------------- /tests/fixtures/sort/numeric_unsorted_ints.expected: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 9 | 9 10 | 10 11 | 11 12 | 12 13 | 13 14 | 14 15 | 15 16 | 16 17 | 17 18 | 18 19 | 19 20 | 20 21 | 21 22 | 22 23 | 23 24 | 24 25 | 25 26 | 26 27 | 27 28 | 28 29 | 29 30 | 30 31 | 31 32 | 32 33 | 33 34 | 34 35 | 35 36 | 36 37 | 37 38 | 38 39 | 39 40 | 40 41 | 41 42 | 42 43 | 43 44 | 44 45 | 45 46 | 46 47 | 47 48 | 48 49 | 49 50 | 50 51 | 51 52 | 52 53 | 53 54 | 54 55 | 55 56 | 56 57 | 57 58 | 58 59 | 59 60 | 60 61 | 61 62 | 62 63 | 63 64 | 64 65 | 65 66 | 66 67 | 67 68 | 68 69 | 69 70 | 70 71 | 71 72 | 72 73 | 73 74 | 74 75 | 75 76 | 76 77 | 77 78 | 78 79 | 79 80 | 80 81 | 81 82 | 82 83 | 83 84 | 84 85 | 85 86 | 86 87 | 87 88 | 88 89 | 89 90 | 90 91 | 91 92 | 92 93 | 93 94 | 94 95 | 95 96 | 96 97 | 97 98 | 98 99 | 99 100 | 100 101 | -------------------------------------------------------------------------------- /tests/fixtures/fold/lorem_ipsum_40_column_word.expected: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, consectetur 2 | adipiscing elit. Nunc interdum suscipit 3 | sem vel ornare. Proin euismod, justo 4 | sed mollis dictum, eros urna ultricies 5 | augue, eu pharetra mi ex id ante. Duis 6 | convallis porttitor aliquam. Nunc vitae 7 | tincidunt ex. Suspendisse iaculis 8 | ligula ac diam consectetur lacinia. 9 | Donec vel velit dui. Etiam fringilla, 10 | dolor quis tempor vehicula, lacus 11 | turpis bibendum velit, et pellentesque 12 | elit odio a magna. Cras vulputate 13 | tortor non libero vehicula euismod. 14 | Aliquam tincidunt nisl eget enim 15 | cursus, viverra sagittis magna commodo. 16 | Cras rhoncus egestas leo nec blandit. 17 | Suspendisse potenti. Etiam ullamcorper 18 | leo vel lacus vestibulum, cursus semper 19 | eros efficitur. In hac habitasse platea 20 | dictumst. Phasellus scelerisque 21 | vehicula fringilla. 22 | -------------------------------------------------------------------------------- /tests/fixtures/dircolors/test1.txt: -------------------------------------------------------------------------------- 1 | .xspf 00;36 2 | NORMAL 00 # no color code at all 3 | FILE 00 # regular file: use no color at all 4 | # Below are the color init strings for the basic file types. A color init 5 | # string consists of one or more of the following numeric codes: 6 | # Attribute codes: 7 | # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed 8 | # Text color codes: 9 | # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white 10 | # Background color codes: 11 | # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white 12 | TERM screen* 13 | .rar 12;34 14 | .tar 01;31 15 | .tgz 01;31 16 | .arc 01;31 17 | ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ... 18 | MISSING 00 # ... and the files they point to 19 | .arj 01;31 20 | .taz 01;31 21 | TERM gnome 22 | SETUID 37;41 # file that is setuid (u+s) 23 | SETGID 30;43 # file that is setgid (g+s) 24 | CAPABILITY 30;41 # file with capability 25 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=uutils 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /tests/fixtures/dircolors/keywords.txt: -------------------------------------------------------------------------------- 1 | NORMAL 00 # no color code at all 2 | FILE 00 # regular file: use no color at all 3 | RESET 0 # reset to "normal" color 4 | Dir 01;34 # directory 5 | LINK 01;36 # symbolic link. (If you set this to 'target' instead of a 6 | multihardlink 00 # regular file with more than one link 7 | fifo 40;33 # pipe 8 | SOCK 01;35 # socket 9 | DOOR 01;35 # door 10 | BLK 40;33;01 # block device driver 11 | CHR 40;33;01 # character device driver 12 | orphan 40;31;01 # symlink to nonexistent file, or non-stat'able file ... 13 | MISSING 00 # ... and the files they point to 14 | setuid 37;41 # file that is setuid (u+s) 15 | SETGID 30;43 # file that is setgid (g+s) 16 | CAPABILITY 30;41 # file with capability 17 | STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w) 18 | Other_writable 34;42 # dir that is other-writable (o+w) and not sticky 19 | STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable 20 | EXEC 01;32 21 | LEFTCODE \e[ 22 | RIGHTCODE m 23 | ENDCODE \xff 24 | -------------------------------------------------------------------------------- /src/uu/whoami/src/platform/windows.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Jordi Boggiano 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | extern crate advapi32; 11 | extern crate uucore; 12 | extern crate winapi; 13 | 14 | use self::winapi::shared::lmcons; 15 | use self::winapi::shared::minwindef; 16 | use self::winapi::um::winnt; 17 | use std::io::{Error, Result}; 18 | use std::mem; 19 | use uucore::wide::FromWide; 20 | 21 | pub unsafe fn getusername() -> Result { 22 | #[allow(deprecated)] 23 | let mut buffer: [winnt::WCHAR; lmcons::UNLEN as usize + 1] = mem::uninitialized(); 24 | let mut len = buffer.len() as minwindef::DWORD; 25 | if advapi32::GetUserNameW(buffer.as_mut_ptr(), &mut len) == 0 { 26 | return Err(Error::last_os_error()); 27 | } 28 | let username = String::from_wide(&buffer[..len as usize - 1]); 29 | Ok(username) 30 | } 31 | -------------------------------------------------------------------------------- /tests/fixtures/ptx/gnu_ext_disabled_roff_no_ref.expected: -------------------------------------------------------------------------------- 1 | .xx "" "" """quotes"", for roff" "" 2 | .xx "" "and some other like" "%a, b#, c$c" "" 3 | .xx "" "maybe" "also~or^" "" 4 | .xx "" "" "and some other like %a, b#, c$c" "" 5 | .xx "" "oh," "and back\slash" "" 6 | .xx "" "and some other like %a," "b#, c$c" "" 7 | .xx "" "oh, and" "back\slash" "" 8 | .xx "" "and some other like %a, b#," "c$c" "" 9 | .xx "" "let's check special" "characters:" "" 10 | .xx "" "let's" "check special characters:" "" 11 | .xx "" """quotes""," "for roff" "" 12 | .xx "" "{brackets}" "for tex" "" 13 | .xx "" "" "hello world!" "" 14 | .xx "" "" "let's check special characters:" "" 15 | .xx "" "and some other" "like %a, b#, c$c" "" 16 | .xx "" "" "maybe also~or^" "" 17 | .xx "" "" "oh, and back\slash" "" 18 | .xx "" "and some" "other like %a, b#, c$c" "" 19 | .xx "" """quotes"", for" "roff" "" 20 | .xx "" "and" "some other like %a, b#, c$c" "" 21 | .xx "" "let's check" "special characters:" "" 22 | .xx "" "{brackets} for" "tex" "" 23 | .xx "" "hello" "world!" "" 24 | .xx "" "" "{brackets} for tex" "" 25 | -------------------------------------------------------------------------------- /tests/fixtures/ptx/gnu_ext_disabled_tex_no_ref.expected: -------------------------------------------------------------------------------- 1 | \xx {}{}{"quotes",}{ for roff}{} 2 | \xx {}{and some other like}{\%a,}{ b\#, c\$c}{} 3 | \xx {}{maybe}{also~or^}{}{} 4 | \xx {}{}{and}{ some other like \%a, b\#, c\$c}{} 5 | \xx {}{oh,}{and}{ back\backslash{}slash}{} 6 | \xx {}{and some other like \%a,}{b\#,}{ c\$c}{} 7 | \xx {}{oh, and}{back\backslash{}slash}{}{} 8 | \xx {}{and some other like \%a, b\#,}{c\$c}{}{} 9 | \xx {}{let's check special}{characters:}{}{} 10 | \xx {}{let's}{check}{ special characters:}{} 11 | \xx {}{"quotes",}{for}{ roff}{} 12 | \xx {}{$\{$brackets$\}$}{for}{ tex}{} 13 | \xx {}{}{hello}{ world!}{} 14 | \xx {}{}{let's}{ check special characters:}{} 15 | \xx {}{and some other}{like}{ \%a, b\#, c\$c}{} 16 | \xx {}{}{maybe}{ also~or^}{} 17 | \xx {}{}{oh,}{ and back\backslash{}slash}{} 18 | \xx {}{and some}{other}{ like \%a, b\#, c\$c}{} 19 | \xx {}{"quotes", for}{roff}{}{} 20 | \xx {}{and}{some}{ other like \%a, b\#, c\$c}{} 21 | \xx {}{let's check}{special}{ characters:}{} 22 | \xx {}{$\{$brackets$\}$ for}{tex}{}{} 23 | \xx {}{hello}{world!}{}{} 24 | \xx {}{}{$\{$brackets$\}$}{ for tex}{} 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Jordi Boggiano 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /src/common/mkmain.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::fs::File; 3 | use std::io::Write; 4 | use std::path::Path; 5 | 6 | static TEMPLATE: &str = "\ 7 | extern crate uu_@UTIL_CRATE@; 8 | extern crate uucore; 9 | 10 | use std::io::Write; 11 | use uu_@UTIL_CRATE@::uumain; 12 | 13 | fn main() { 14 | uucore::panic::install_sigpipe_hook(); 15 | 16 | let code = uumain(uucore::args().collect()); 17 | // Since stdout is line-buffered by default, we need to ensure any pending 18 | // writes are flushed before exiting. Ideally, this should be enforced by 19 | // each utility. 20 | // 21 | // See: https://github.com/rust-lang/rust/issues/23818 22 | // 23 | std::io::stdout().flush().expect(\"could not flush stdout\"); 24 | std::process::exit(code); 25 | } 26 | "; 27 | 28 | pub fn main() { 29 | let out_dir = env::var("OUT_DIR").unwrap(); 30 | let pkgname = env::var("CARGO_PKG_NAME").unwrap(); 31 | 32 | let main = TEMPLATE.replace("@UTIL_CRATE@", &pkgname); 33 | let mut file = File::create(&Path::new(&out_dir).join("main.rs")).unwrap(); 34 | 35 | write!(file, "{}", main).unwrap(); 36 | } 37 | -------------------------------------------------------------------------------- /src/uu/base32/src/base32.rs: -------------------------------------------------------------------------------- 1 | // This file is part of the uutils coreutils package. 2 | // 3 | // (c) Jian Zeng 4 | // 5 | // For the full copyright and license information, please view the LICENSE file 6 | // that was distributed with this source code. 7 | // 8 | 9 | #![crate_name = "uu_base32"] 10 | 11 | #[macro_use] 12 | extern crate uucore; 13 | use uucore::encoding::Format; 14 | 15 | #[path = "../../base64/src/base_common.rs"] 16 | mod base_common; 17 | 18 | static SYNTAX: &str = "[OPTION]... [FILE]"; 19 | static SUMMARY: &str = "Base32 encode or decode FILE, or standard input, to standard output."; 20 | static LONG_HELP: &str = " 21 | With no FILE, or when FILE is -, read standard input. 22 | 23 | The data are encoded as described for the base32 alphabet in RFC 24 | 4648. When decoding, the input may contain newlines in addition 25 | to the bytes of the formal base32 alphabet. Use --ignore-garbage 26 | to attempt to recover from any other non-alphabet bytes in the 27 | encoded stream. 28 | "; 29 | 30 | pub fn uumain(args: Vec) -> i32 { 31 | base_common::execute(args, SYNTAX, SUMMARY, LONG_HELP, Format::Base32) 32 | } 33 | -------------------------------------------------------------------------------- /src/uu/tail/src/platform/unix.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Alexander Batischev 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | extern crate libc; 11 | 12 | use std::io::Error; 13 | 14 | pub type Pid = libc::pid_t; 15 | 16 | pub struct ProcessChecker { 17 | pid: self::Pid, 18 | } 19 | 20 | impl ProcessChecker { 21 | pub fn new(process_id: self::Pid) -> ProcessChecker { 22 | ProcessChecker { pid: process_id } 23 | } 24 | 25 | // Borrowing mutably to be aligned with Windows implementation 26 | pub fn is_dead(&mut self) -> bool { 27 | unsafe { libc::kill(self.pid, 0) != 0 && get_errno() != libc::EPERM } 28 | } 29 | } 30 | 31 | impl Drop for ProcessChecker { 32 | fn drop(&mut self) {} 33 | } 34 | 35 | pub fn supports_pid_checks(pid: self::Pid) -> bool { 36 | unsafe { !(libc::kill(pid, 0) != 0 && get_errno() == libc::ENOSYS) } 37 | } 38 | 39 | #[inline] 40 | fn get_errno() -> i32 { 41 | Error::last_os_error().raw_os_error().unwrap() 42 | } 43 | -------------------------------------------------------------------------------- /src/uu/base64/src/base64.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_base64"] 2 | 3 | // This file is part of the uutils coreutils package. 4 | // 5 | // (c) Jordy Dickinson 6 | // (c) Jian Zeng 7 | // 8 | // For the full copyright and license information, please view the LICENSE file 9 | // that was distributed with this source code. 10 | // 11 | 12 | #[macro_use] 13 | extern crate uucore; 14 | use uucore::encoding::Format; 15 | 16 | mod base_common; 17 | 18 | static SYNTAX: &str = "[OPTION]... [FILE]"; 19 | static SUMMARY: &str = "Base64 encode or decode FILE, or standard input, to standard output."; 20 | static LONG_HELP: &str = " 21 | With no FILE, or when FILE is -, read standard input. 22 | 23 | The data are encoded as described for the base64 alphabet in RFC 24 | 3548. When decoding, the input may contain newlines in addition 25 | to the bytes of the formal base64 alphabet. Use --ignore-garbage 26 | to attempt to recover from any other non-alphabet bytes in the 27 | encoded stream. 28 | "; 29 | 30 | pub fn uumain(args: Vec) -> i32 { 31 | base_common::execute(args, SYNTAX, SUMMARY, LONG_HELP, Format::Base64) 32 | } 33 | -------------------------------------------------------------------------------- /src/uu/stdbuf/build.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::fs; 3 | use std::path::Path; 4 | 5 | #[path = "../../common/mkmain.rs"] 6 | mod mkmain; 7 | 8 | #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "windows")))] 9 | mod platform { 10 | pub const DYLIB_EXT: &str = ".so"; 11 | } 12 | 13 | #[cfg(any(target_os = "macos", target_os = "ios"))] 14 | mod platform { 15 | pub const DYLIB_EXT: &str = ".dylib"; 16 | } 17 | 18 | #[cfg(target_os = "windows")] 19 | mod platform { 20 | pub const DYLIB_EXT: &str = ".dll"; 21 | } 22 | 23 | fn main() { 24 | mkmain::main(); 25 | 26 | let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("Could not find manifest dir"); 27 | let profile = env::var("PROFILE").expect("Could not determine profile"); 28 | 29 | let out_dir = env::var("OUT_DIR").unwrap(); 30 | let libstdbuf = format!( 31 | "{}/../../../{}/{}/deps/liblibstdbuf{}", 32 | manifest_dir, 33 | env::var("CARGO_TARGET_DIR").unwrap_or_else(|_| "target".to_string()), 34 | profile, 35 | platform::DYLIB_EXT 36 | ); 37 | 38 | fs::copy(libstdbuf, Path::new(&out_dir).join("libstdbuf.so")).unwrap(); 39 | } 40 | -------------------------------------------------------------------------------- /tests/test_realpath.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_current_directory() { 5 | let (at, mut ucmd) = at_and_ucmd!(); 6 | let actual = ucmd.arg(".").run().stdout; 7 | let expect = at.root_dir_resolved() + "\n"; 8 | println!("actual: {:?}", actual); 9 | println!("expect: {:?}", expect); 10 | assert_eq!(actual, expect); 11 | } 12 | 13 | #[test] 14 | fn test_long_redirection_to_current_dir() { 15 | let (at, mut ucmd) = at_and_ucmd!(); 16 | // Create a 256-character path to current directory 17 | let dir = path_concat!(".", ..128); 18 | let actual = ucmd.arg(dir).run().stdout; 19 | let expect = at.root_dir_resolved() + "\n"; 20 | println!("actual: {:?}", actual); 21 | println!("expect: {:?}", expect); 22 | assert_eq!(actual, expect); 23 | } 24 | 25 | #[test] 26 | fn test_long_redirection_to_root() { 27 | // Create a 255-character path to root 28 | let dir = path_concat!("..", ..85); 29 | let actual = new_ucmd!().arg(dir).run().stdout; 30 | let expect = get_root_path().to_owned() + "\n"; 31 | println!("actual: {:?}", actual); 32 | println!("expect: {:?}", expect); 33 | assert_eq!(actual, expect); 34 | } 35 | -------------------------------------------------------------------------------- /tests/fixtures/wc/moby_dick.txt: -------------------------------------------------------------------------------- 1 | Call me Ishmael. Some years ago - never mind how long 2 | precisely - having little or no money in my purse, and nothing 3 | particular to interest me on shore, I thought I would sail about a 4 | little and see the watery part of the world. It is a way I have of 5 | driving off the spleen and regulating the circulation. Whenever I 6 | find myself growing grim about the mouth; whenever it is a damp, 7 | drizzly November in my soul; whenever I find myself involuntarily 8 | pausing before coffin warehouses, and bringing up the rear of every 9 | funeral I meet; and especially whenever my hypos get such an upper 10 | hand of me, that it requires a strong moral principle to prevent me 11 | from deliberately stepping into the street, and methodically 12 | knocking people's hats off - then, I account it high time to get to 13 | sea as soon as I can. This is my substitute for pistol and ball. 14 | With a philosophical flourish Cato throws himself upon his sword; I 15 | quietly take to the ship. There is nothing surprising in this. If 16 | they but knew it, almost all men in their degree, some time or 17 | other, cherish very nearly the same feelings towards the ocean with 18 | me. 19 | -------------------------------------------------------------------------------- /src/uu/printf/src/tokenize/num_format/formatters/floatf.rs: -------------------------------------------------------------------------------- 1 | //! formatter for %f %F common-notation floating-point subs 2 | use super::super::format_field::FormatField; 3 | use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; 4 | use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnalysis}; 5 | 6 | pub struct Floatf { 7 | as_num: f64, 8 | } 9 | impl Floatf { 10 | pub fn new() -> Floatf { 11 | Floatf { as_num: 0.0 } 12 | } 13 | } 14 | impl Formatter for Floatf { 15 | fn get_primitive( 16 | &self, 17 | field: &FormatField, 18 | inprefix: &InPrefix, 19 | str_in: &str, 20 | ) -> Option { 21 | let second_field = field.second_field.unwrap_or(6) + 1; 22 | let analysis = 23 | FloatAnalysis::analyze(&str_in, inprefix, None, Some(second_field as usize), false); 24 | let f = get_primitive_dec( 25 | inprefix, 26 | &str_in[inprefix.offset..], 27 | &analysis, 28 | second_field as usize, 29 | None, 30 | ); 31 | Some(f) 32 | } 33 | fn primitive_to_str(&self, prim: &FormatPrimitive, field: FormatField) -> String { 34 | primitive_to_str_common(prim, &field) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/uu/printf/src/tokenize/token.rs: -------------------------------------------------------------------------------- 1 | //! Traits and enums dealing with Tokenization of printf Format String 2 | use itertools::PutBackN; 3 | use std::iter::Peekable; 4 | use std::slice::Iter; 5 | use std::str::Chars; 6 | 7 | // A token object is an object that can print the expected output 8 | // of a contiguous segment of the format string, and 9 | // requires at most 1 argusegment 10 | pub trait Token { 11 | fn print(&self, args: &mut Peekable>); 12 | } 13 | 14 | // A tokenizer object is an object that takes an iterator 15 | // at a position in a format string, and sees whether 16 | // it can return a token of a type it knows how to produce 17 | // if so, return the token, move the iterator past the 18 | // format string text the token represents, and if an 19 | // argument is used move the argument iter forward one 20 | 21 | // creating token of a format string segment should also cause 22 | // printing of that token's value. Essentially tokenizing 23 | // a whole format string will print the format string and consume 24 | // a number of arguments equal to the number of argument-using tokens 25 | 26 | pub trait Tokenizer { 27 | fn from_it( 28 | it: &mut PutBackN, 29 | args: &mut Peekable>, 30 | ) -> Option>; 31 | } 32 | -------------------------------------------------------------------------------- /tests/test_link.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_link_existing_file() { 5 | let (at, mut ucmd) = at_and_ucmd!(); 6 | let file = "test_link_existing_file"; 7 | let link = "test_link_existing_file_link"; 8 | 9 | at.touch(file); 10 | at.write(file, "foobar"); 11 | assert!(at.file_exists(file)); 12 | 13 | ucmd.args(&[file, link]).succeeds().no_stderr(); 14 | assert!(at.file_exists(file)); 15 | assert!(at.file_exists(link)); 16 | assert_eq!(at.read(file), at.read(link)); 17 | } 18 | 19 | #[test] 20 | fn test_link_no_circular() { 21 | let (at, mut ucmd) = at_and_ucmd!(); 22 | let link = "test_link_no_circular"; 23 | 24 | ucmd.args(&[link, link]) 25 | .fails() 26 | .stderr_is("link: error: No such file or directory (os error 2)\n"); 27 | assert!(!at.file_exists(link)); 28 | } 29 | 30 | #[test] 31 | fn test_link_nonexistent_file() { 32 | let (at, mut ucmd) = at_and_ucmd!(); 33 | let file = "test_link_nonexistent_file"; 34 | let link = "test_link_nonexistent_file_link"; 35 | 36 | ucmd.args(&[file, link]) 37 | .fails() 38 | .stderr_is("link: error: No such file or directory (os error 2)\n"); 39 | assert!(!at.file_exists(file)); 40 | assert!(!at.file_exists(link)); 41 | } 42 | -------------------------------------------------------------------------------- /tests/fixtures/ptx/gnu_ext_disabled_roff_auto_ref.expected: -------------------------------------------------------------------------------- 1 | .xx "" "" """quotes"", for roff" "" "input:3" 2 | .xx "" "and some other like" "%a, b#, c$c" "" "input:5" 3 | .xx "" "maybe" "also~or^" "" "input:6" 4 | .xx "" "" "and some other like %a, b#, c$c" "" "input:5" 5 | .xx "" "oh," "and back\slash" "" "input:7" 6 | .xx "" "and some other like %a," "b#, c$c" "" "input:5" 7 | .xx "" "oh, and" "back\slash" "" "input:7" 8 | .xx "" "and some other like %a, b#," "c$c" "" "input:5" 9 | .xx "" "let's check special" "characters:" "" "input:2" 10 | .xx "" "let's" "check special characters:" "" "input:2" 11 | .xx "" """quotes""," "for roff" "" "input:3" 12 | .xx "" "{brackets}" "for tex" "" "input:4" 13 | .xx "" "" "hello world!" "" "input:1" 14 | .xx "" "" "let's check special characters:" "" "input:2" 15 | .xx "" "and some other" "like %a, b#, c$c" "" "input:5" 16 | .xx "" "" "maybe also~or^" "" "input:6" 17 | .xx "" "" "oh, and back\slash" "" "input:7" 18 | .xx "" "and some" "other like %a, b#, c$c" "" "input:5" 19 | .xx "" """quotes"", for" "roff" "" "input:3" 20 | .xx "" "and" "some other like %a, b#, c$c" "" "input:5" 21 | .xx "" "let's check" "special characters:" "" "input:2" 22 | .xx "" "{brackets} for" "tex" "" "input:4" 23 | .xx "" "hello" "world!" "" "input:1" 24 | .xx "" "" "{brackets} for tex" "" "input:4" 25 | -------------------------------------------------------------------------------- /tests/fixtures/ptx/gnu_ext_disabled_tex_auto_ref.expected: -------------------------------------------------------------------------------- 1 | \xx {}{}{"quotes",}{ for roff}{}{input:3} 2 | \xx {}{and some other like}{\%a,}{ b\#, c\$c}{}{input:5} 3 | \xx {}{maybe}{also~or^}{}{}{input:6} 4 | \xx {}{}{and}{ some other like \%a, b\#, c\$c}{}{input:5} 5 | \xx {}{oh,}{and}{ back\backslash{}slash}{}{input:7} 6 | \xx {}{and some other like \%a,}{b\#,}{ c\$c}{}{input:5} 7 | \xx {}{oh, and}{back\backslash{}slash}{}{}{input:7} 8 | \xx {}{and some other like \%a, b\#,}{c\$c}{}{}{input:5} 9 | \xx {}{let's check special}{characters:}{}{}{input:2} 10 | \xx {}{let's}{check}{ special characters:}{}{input:2} 11 | \xx {}{"quotes",}{for}{ roff}{}{input:3} 12 | \xx {}{$\{$brackets$\}$}{for}{ tex}{}{input:4} 13 | \xx {}{}{hello}{ world!}{}{input:1} 14 | \xx {}{}{let's}{ check special characters:}{}{input:2} 15 | \xx {}{and some other}{like}{ \%a, b\#, c\$c}{}{input:5} 16 | \xx {}{}{maybe}{ also~or^}{}{input:6} 17 | \xx {}{}{oh,}{ and back\backslash{}slash}{}{input:7} 18 | \xx {}{and some}{other}{ like \%a, b\#, c\$c}{}{input:5} 19 | \xx {}{"quotes", for}{roff}{}{}{input:3} 20 | \xx {}{and}{some}{ other like \%a, b\#, c\$c}{}{input:5} 21 | \xx {}{let's check}{special}{ characters:}{}{input:2} 22 | \xx {}{$\{$brackets$\}$ for}{tex}{}{}{input:4} 23 | \xx {}{hello}{world!}{}{}{input:1} 24 | \xx {}{}{$\{$brackets$\}$}{ for tex}{}{input:4} 25 | -------------------------------------------------------------------------------- /src/uu/hostid/src/hostid.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_hostid"] 2 | 3 | /* 4 | * This file is part of the uutils coreutils package. 5 | * 6 | * (c) Maciej Dziardziel 7 | * 8 | * For the full copyright and license information, please view the LICENSE file 9 | * that was distributed with this source code. 10 | */ 11 | 12 | extern crate libc; 13 | 14 | #[macro_use] 15 | extern crate uucore; 16 | 17 | use libc::c_long; 18 | 19 | static SYNTAX: &str = "[options]"; 20 | static SUMMARY: &str = ""; 21 | static LONG_HELP: &str = ""; 22 | 23 | // currently rust libc interface doesn't include gethostid 24 | extern "C" { 25 | pub fn gethostid() -> c_long; 26 | } 27 | 28 | pub fn uumain(args: Vec) -> i32 { 29 | new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); 30 | hostid(); 31 | 0 32 | } 33 | 34 | fn hostid() { 35 | /* 36 | * POSIX says gethostid returns a "32-bit identifier" but is silent 37 | * whether it's sign-extended. Turn off any sign-extension. This 38 | * is a no-op unless unsigned int is wider than 32 bits. 39 | */ 40 | 41 | let mut result: c_long; 42 | unsafe { 43 | result = gethostid(); 44 | } 45 | 46 | #[allow(overflowing_literals)] 47 | let mask = 0xffff_ffff; 48 | 49 | result &= mask; 50 | println!("{:0>8x}", result); 51 | } 52 | -------------------------------------------------------------------------------- /util/show-utils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # spell-checker:ignore (utils) cksum dircolors hashsum mkdir mktemp printenv printf readlink realpath relpath rmdir shuf tsort unexpand uutils 4 | # spell-checker:ignore (jq) deps startswith 5 | 6 | # refs: , 7 | 8 | # default ("Tier 1" cross-platform) utility list 9 | default_utils="base32 base64 basename cat cksum comm cp cut date dircolors dirname echo env expand expr factor false fmt fold hashsum head join link ln ls mkdir mktemp more mv nl od paste printenv printf ptx pwd readlink realpath relpath rm rmdir seq shred shuf sleep sort split sum tac tail tee test tr true truncate tsort unexpand uniq wc yes" 10 | 11 | # `jq` available? 12 | unset JQ 13 | jq --version 1>/dev/null 2>&1 14 | if [ $? -eq 0 ]; then export JQ="jq"; fi 15 | 16 | if [ -z "${JQ}" ]; then 17 | echo 'WARN: missing `jq` (install with `sudo apt install jq`); falling back to default (only fully cross-platform) utility list' 1>&2 18 | echo $default_utils 19 | else 20 | cargo metadata $* --format-version 1 | jq -r "[.resolve.nodes[] | {id: .id, deps: [.deps[].name]}] | .[] | select(.id|startswith(\"uutils\")) | [.deps[] | select(startswith(\"uu_\"))] | [.[] | sub(\"^uu_\"; \"\")] | join(\" \")" 21 | fi 22 | -------------------------------------------------------------------------------- /tests/test_tac.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_stdin_default() { 5 | new_ucmd!() 6 | .pipe_in("100\n200\n300\n400\n500") 7 | .run() 8 | .stdout_is("500400\n300\n200\n100\n"); 9 | } 10 | 11 | #[test] 12 | fn test_stdin_non_newline_separator() { 13 | new_ucmd!() 14 | .args(&["-s", ":"]) 15 | .pipe_in("100:200:300:400:500") 16 | .run() 17 | .stdout_is("500400:300:200:100:"); 18 | } 19 | 20 | #[test] 21 | fn test_stdin_non_newline_separator_before() { 22 | new_ucmd!() 23 | .args(&["-b", "-s", ":"]) 24 | .pipe_in("100:200:300:400:500") 25 | .run() 26 | .stdout_is("500:400:300:200:100"); 27 | } 28 | 29 | #[test] 30 | fn test_single_default() { 31 | new_ucmd!() 32 | .arg("prime_per_line.txt") 33 | .run() 34 | .stdout_is_fixture("prime_per_line.expected"); 35 | } 36 | 37 | #[test] 38 | fn test_single_non_newline_separator() { 39 | new_ucmd!() 40 | .args(&["-s", ":", "delimited_primes.txt"]) 41 | .run() 42 | .stdout_is_fixture("delimited_primes.expected"); 43 | } 44 | 45 | #[test] 46 | fn test_single_non_newline_separator_before() { 47 | new_ucmd!() 48 | .args(&["-b", "-s", ":", "delimited_primes.txt"]) 49 | .run() 50 | .stdout_is_fixture("delimited_primes_before.expected"); 51 | } 52 | -------------------------------------------------------------------------------- /src/uu/link/src/link.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_link"] 2 | 3 | /* 4 | * This file is part of the uutils coreutils package. 5 | * 6 | * (c) Michael Gehring 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | #[macro_use] 13 | extern crate uucore; 14 | 15 | use std::fs::hard_link; 16 | use std::io::Error; 17 | use std::path::Path; 18 | 19 | static SYNTAX: &str = "[OPTIONS] FILE1 FILE2"; 20 | static SUMMARY: &str = "Create a link named FILE2 to FILE1"; 21 | static LONG_HELP: &str = ""; 22 | 23 | pub fn normalize_error_message(e: Error) -> String { 24 | match e.raw_os_error() { 25 | Some(2) => String::from("No such file or directory (os error 2)"), 26 | _ => format!("{}", e), 27 | } 28 | } 29 | 30 | pub fn uumain(args: Vec) -> i32 { 31 | let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); 32 | if matches.free.len() != 2 { 33 | crash!(1, "{}", msg_wrong_number_of_arguments!(2)); 34 | } 35 | 36 | let old = Path::new(&matches.free[0]); 37 | let new = Path::new(&matches.free[1]); 38 | 39 | match hard_link(old, new) { 40 | Ok(_) => 0, 41 | Err(err) => { 42 | show_error!("{}", normalize_error_message(err)); 43 | 1 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/uu/printf/src/tokenize/num_format/formatters/scif.rs: -------------------------------------------------------------------------------- 1 | //! formatter for %e %E scientific notation subs 2 | use super::super::format_field::FormatField; 3 | use super::super::formatter::{FormatPrimitive, Formatter, InPrefix}; 4 | use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnalysis}; 5 | 6 | pub struct Scif { 7 | as_num: f64, 8 | } 9 | impl Scif { 10 | pub fn new() -> Scif { 11 | Scif { as_num: 0.0 } 12 | } 13 | } 14 | impl Formatter for Scif { 15 | fn get_primitive( 16 | &self, 17 | field: &FormatField, 18 | inprefix: &InPrefix, 19 | str_in: &str, 20 | ) -> Option { 21 | let second_field = field.second_field.unwrap_or(6) + 1; 22 | let analysis = FloatAnalysis::analyze( 23 | str_in, 24 | inprefix, 25 | Some(second_field as usize + 1), 26 | None, 27 | false, 28 | ); 29 | let f = get_primitive_dec( 30 | inprefix, 31 | &str_in[inprefix.offset..], 32 | &analysis, 33 | second_field as usize, 34 | Some(*field.field_char == 'E'), 35 | ); 36 | Some(f) 37 | } 38 | fn primitive_to_str(&self, prim: &FormatPrimitive, field: FormatField) -> String { 39 | primitive_to_str_common(prim, &field) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/uu/cksum/build.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Alex Lyon 5 | * (c) Michael Gehring 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | use std::env; 12 | use std::fs::File; 13 | use std::io::Write; 14 | use std::path::Path; 15 | 16 | const CRC_TABLE_LEN: usize = 256; 17 | 18 | #[path = "../../common/mkmain.rs"] 19 | mod mkmain; 20 | 21 | fn main() { 22 | mkmain::main(); 23 | 24 | let out_dir = env::var("OUT_DIR").unwrap(); 25 | 26 | let mut table = Vec::with_capacity(CRC_TABLE_LEN); 27 | for num in 0..CRC_TABLE_LEN { 28 | table.push(crc_entry(num as u8) as u32); 29 | } 30 | let file = File::create(&Path::new(&out_dir).join("crc_table.rs")).unwrap(); 31 | write!( 32 | &file, 33 | "#[allow(clippy::unreadable_literal)]\nconst CRC_TABLE: [u32; {}] = {:?};", 34 | CRC_TABLE_LEN, table 35 | ) 36 | .unwrap(); 37 | } 38 | 39 | #[inline] 40 | fn crc_entry(input: u8) -> u32 { 41 | let mut crc = (input as u32) << 24; 42 | 43 | for _ in 0..8 { 44 | if crc & 0x8000_0000 != 0 { 45 | crc <<= 1; 46 | crc ^= 0x04c1_1db7; 47 | } else { 48 | crc <<= 1; 49 | } 50 | } 51 | 52 | crc 53 | } 54 | -------------------------------------------------------------------------------- /src/uu/mknod/src/parsemode.rs: -------------------------------------------------------------------------------- 1 | extern crate libc; 2 | use libc::{mode_t, S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR}; 3 | 4 | use uucore::mode; 5 | 6 | pub fn parse_mode(mode: Option) -> Result { 7 | let fperm = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; 8 | if let Some(mode) = mode { 9 | let arr: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; 10 | let result = if mode.contains(arr) { 11 | mode::parse_numeric(fperm as u32, mode.as_str()) 12 | } else { 13 | mode::parse_symbolic(fperm as u32, mode.as_str(), true) 14 | }; 15 | result.map(|mode| mode as mode_t) 16 | } else { 17 | Ok(fperm) 18 | } 19 | } 20 | 21 | #[test] 22 | fn symbolic_modes() { 23 | assert_eq!(parse_mode(Some("u+x".to_owned())).unwrap(), 0o766); 24 | assert_eq!(parse_mode(Some("+x".to_owned())).unwrap(), 0o777); 25 | assert_eq!(parse_mode(Some("a-w".to_owned())).unwrap(), 0o444); 26 | assert_eq!(parse_mode(Some("g-r".to_owned())).unwrap(), 0o626); 27 | } 28 | 29 | #[test] 30 | fn numeric_modes() { 31 | assert_eq!(parse_mode(Some("644".to_owned())).unwrap(), 0o644); 32 | assert_eq!(parse_mode(Some("+100".to_owned())).unwrap(), 0o766); 33 | assert_eq!(parse_mode(Some("-4".to_owned())).unwrap(), 0o662); 34 | assert_eq!(parse_mode(None).unwrap(), 0o666); 35 | } 36 | -------------------------------------------------------------------------------- /tests/test_sum.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_bsd_single_file() { 5 | new_ucmd!() 6 | .arg("lorem_ipsum.txt") 7 | .succeeds() 8 | .stdout_only_fixture("bsd_single_file.expected"); 9 | } 10 | 11 | #[test] 12 | fn test_bsd_multiple_files() { 13 | new_ucmd!() 14 | .arg("lorem_ipsum.txt") 15 | .arg("alice_in_wonderland.txt") 16 | .succeeds() 17 | .stdout_only_fixture("bsd_multiple_files.expected"); 18 | } 19 | 20 | #[test] 21 | fn test_bsd_stdin() { 22 | new_ucmd!() 23 | .pipe_in_fixture("lorem_ipsum.txt") 24 | .succeeds() 25 | .stdout_only_fixture("bsd_stdin.expected"); 26 | } 27 | 28 | #[test] 29 | fn test_sysv_single_file() { 30 | new_ucmd!() 31 | .arg("-s") 32 | .arg("lorem_ipsum.txt") 33 | .succeeds() 34 | .stdout_only_fixture("sysv_single_file.expected"); 35 | } 36 | 37 | #[test] 38 | fn test_sysv_multiple_files() { 39 | new_ucmd!() 40 | .arg("-s") 41 | .arg("lorem_ipsum.txt") 42 | .arg("alice_in_wonderland.txt") 43 | .succeeds() 44 | .stdout_only_fixture("sysv_multiple_files.expected"); 45 | } 46 | 47 | #[test] 48 | fn test_sysv_stdin() { 49 | new_ucmd!() 50 | .arg("-s") 51 | .pipe_in_fixture("lorem_ipsum.txt") 52 | .succeeds() 53 | .stdout_only_fixture("sysv_stdin.expected"); 54 | } 55 | -------------------------------------------------------------------------------- /src/uu/install/src/mode.rs: -------------------------------------------------------------------------------- 1 | extern crate libc; 2 | 3 | use std::fs; 4 | use std::path::Path; 5 | #[cfg(not(windows))] 6 | use uucore::mode; 7 | 8 | /// Takes a user-supplied string and tries to parse to u16 mode bitmask. 9 | pub fn parse(mode_string: &str, considering_dir: bool) -> Result { 10 | let numbers: &[char] = &['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; 11 | 12 | // Passing 000 as the existing permissions seems to mirror GNU behaviour. 13 | if mode_string.contains(numbers) { 14 | mode::parse_numeric(0, mode_string) 15 | } else { 16 | mode::parse_symbolic(0, mode_string, considering_dir) 17 | } 18 | } 19 | 20 | /// chmod a file or directory on UNIX. 21 | /// 22 | /// Adapted from mkdir.rs. Handles own error printing. 23 | /// 24 | #[cfg(any(unix, target_os = "redox"))] 25 | pub fn chmod(path: &Path, mode: u32) -> Result<(), ()> { 26 | use std::os::unix::fs::PermissionsExt; 27 | fs::set_permissions(path, fs::Permissions::from_mode(mode)).map_err(|err| { 28 | show_info!("{}: chmod failed with error {}", path.display(), err); 29 | }) 30 | } 31 | 32 | /// chmod a file or directory on Windows. 33 | /// 34 | /// Adapted from mkdir.rs. 35 | /// 36 | #[cfg(windows)] 37 | pub fn chmod(path: &Path, mode: u32) -> Result<(), ()> { 38 | // chmod on Windows only sets the readonly flag, which isn't even honored on directories 39 | Ok(()) 40 | } 41 | -------------------------------------------------------------------------------- /tests/fixtures/dircolors/csh_def.expected: -------------------------------------------------------------------------------- 1 | setenv LS_COLORS 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:' 2 | -------------------------------------------------------------------------------- /src/uu/logname/src/logname.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_logname"] 2 | 3 | /* 4 | * This file is part of the uutils coreutils package. 5 | * 6 | * (c) Benoit Benedetti 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /* last synced with: logname (GNU coreutils) 8.22 */ 13 | 14 | extern crate libc; 15 | 16 | #[macro_use] 17 | extern crate uucore; 18 | 19 | use std::ffi::CStr; 20 | 21 | extern "C" { 22 | // POSIX requires using getlogin (or equivalent code) 23 | pub fn getlogin() -> *const libc::c_char; 24 | } 25 | 26 | fn get_userlogin() -> Option { 27 | unsafe { 28 | let login: *const libc::c_char = getlogin(); 29 | if login.is_null() { 30 | None 31 | } else { 32 | Some(String::from_utf8_lossy(CStr::from_ptr(login).to_bytes()).to_string()) 33 | } 34 | } 35 | } 36 | 37 | static SYNTAX: &str = ""; 38 | static SUMMARY: &str = "Print user's login name"; 39 | static LONG_HELP: &str = ""; 40 | 41 | pub fn uumain(args: Vec) -> i32 { 42 | new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); 43 | 44 | exec(); 45 | 46 | 0 47 | } 48 | 49 | fn exec() { 50 | match get_userlogin() { 51 | Some(userlogin) => println!("{}", userlogin), 52 | None => show_error!("no login name"), 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/fixtures/dircolors/bash_def.expected: -------------------------------------------------------------------------------- 1 | LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'; 2 | export LS_COLORS 3 | -------------------------------------------------------------------------------- /src/uu/groups/src/groups.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_groups"] 2 | 3 | // This file is part of the uutils coreutils package. 4 | // 5 | // (c) Alan Andrade 6 | // (c) Jian Zeng 7 | // 8 | // For the full copyright and license information, please view the LICENSE 9 | // file that was distributed with this source code. 10 | // 11 | // 12 | 13 | #[macro_use] 14 | extern crate uucore; 15 | use uucore::entries::{get_groups, gid2grp, Locate, Passwd}; 16 | 17 | static SYNTAX: &str = "[user]"; 18 | static SUMMARY: &str = "display current group names"; 19 | 20 | pub fn uumain(args: Vec) -> i32 { 21 | let matches = new_coreopts!(SYNTAX, SUMMARY, "").parse(args); 22 | 23 | if matches.free.is_empty() { 24 | println!( 25 | "{}", 26 | get_groups() 27 | .unwrap() 28 | .iter() 29 | .map(|&g| gid2grp(g).unwrap()) 30 | .collect::>() 31 | .join(" ") 32 | ); 33 | } else if let Ok(p) = Passwd::locate(matches.free[0].as_str()) { 34 | println!( 35 | "{}", 36 | p.belongs_to() 37 | .iter() 38 | .map(|&g| gid2grp(g).unwrap()) 39 | .collect::>() 40 | .join(" ") 41 | ); 42 | } else { 43 | crash!(1, "unknown user {}", matches.free[0]); 44 | } 45 | 46 | 0 47 | } 48 | -------------------------------------------------------------------------------- /tests/test_unlink.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_unlink_file() { 5 | let (at, mut ucmd) = at_and_ucmd!(); 6 | let file = "test_unlink_file"; 7 | 8 | at.touch(file); 9 | 10 | ucmd.arg(file).succeeds().no_stderr(); 11 | 12 | assert!(!at.file_exists(file)); 13 | } 14 | 15 | #[test] 16 | fn test_unlink_multiple_files() { 17 | let (at, mut ucmd) = at_and_ucmd!(); 18 | let file_a = "test_unlink_multiple_file_a"; 19 | let file_b = "test_unlink_multiple_file_b"; 20 | 21 | at.touch(file_a); 22 | at.touch(file_b); 23 | 24 | ucmd.arg(file_a).arg(file_b).fails().stderr_is( 25 | "unlink: error: extra operand: 'test_unlink_multiple_file_b'\nTry 'unlink --help' \ 26 | for more information.\n", 27 | ); 28 | } 29 | 30 | #[test] 31 | fn test_unlink_directory() { 32 | let (at, mut ucmd) = at_and_ucmd!(); 33 | let dir = "test_unlink_empty_directory"; 34 | 35 | at.mkdir(dir); 36 | 37 | ucmd.arg(dir).fails().stderr_is( 38 | "unlink: error: cannot unlink 'test_unlink_empty_directory': Not a regular file \ 39 | or symlink\n", 40 | ); 41 | } 42 | 43 | #[test] 44 | fn test_unlink_nonexistent() { 45 | let file = "test_unlink_nonexistent"; 46 | 47 | new_ucmd!().arg(file).fails().stderr_is( 48 | "unlink: error: Cannot stat 'test_unlink_nonexistent': No such file or directory \ 49 | (os error 2)\n", 50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /util/show-utils.BAT: -------------------------------------------------------------------------------- 1 | @setLocal 2 | @echo off 3 | 4 | @rem ::# spell-checker:ignore (CMD) ERRORLEVEL 5 | @rem ::# spell-checker:ignore (utils) cksum dircolors hashsum mkdir mktemp printenv printf readlink realpath relpath rmdir shuf tsort unexpand uutils 6 | @rem ::# spell-checker:ignore (jq) deps startswith 7 | 8 | @rem refs: , 9 | 10 | @rem :: default ("Tier 1" cross-platform) utility list 11 | set "default_utils=base32 base64 basename cat cksum comm cp cut date dircolors dirname echo env expand expr factor false fmt fold hashsum head join link ln ls mkdir mktemp more mv nl od paste printenv printf ptx pwd readlink realpath relpath rm rmdir seq shred shuf sleep sort split sum tac tail tee test tr true truncate tsort unexpand uniq wc yes" 12 | 13 | @:: `jq` available? 14 | set "JQ=" 15 | set "ERRORLEVEL=" 16 | jq --version 1>NUL 2>&1 17 | if NOT ERRORLEVEL 1 ( set "JQ=jq" ) 18 | 19 | if NOT DEFINED JQ ( 20 | echo WARN: missing `jq` ^(install with `scoop install jq`^)^; falling back to default ^(only fully cross-platform^) util list 1>&2 21 | echo %default_utils% 22 | ) else ( 23 | cargo metadata %* --format-version 1 | jq -r "[.resolve.nodes[] | {id: .id, deps: [.deps[].name]}] | .[] | select(.id|startswith(\"uutils\")) | [.deps[] | select(startswith(\"uu_\"))] | [.[] | sub(\"^uu_\"; \"\")] | join(\" \")" 24 | ) 25 | -------------------------------------------------------------------------------- /tests/test_expr.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_simple_arithmetic() { 5 | new_ucmd!().args(&["1", "+", "1"]).run().stdout_is("2\n"); 6 | 7 | new_ucmd!().args(&["1", "-", "1"]).run().stdout_is("0\n"); 8 | 9 | new_ucmd!().args(&["3", "*", "2"]).run().stdout_is("6\n"); 10 | 11 | new_ucmd!().args(&["4", "/", "2"]).run().stdout_is("2\n"); 12 | } 13 | 14 | #[test] 15 | fn test_complex_arithmetic() { 16 | let run = new_ucmd!() 17 | .args(&["9223372036854775807", "+", "9223372036854775807"]) 18 | .run(); 19 | run.stdout_is(""); 20 | run.stderr_is("expr: error: +: Numerical result out of range"); 21 | 22 | let run = new_ucmd!().args(&["9", "/", "0"]).run(); 23 | run.stdout_is(""); 24 | run.stderr_is("expr: error: division by zero"); 25 | } 26 | 27 | #[test] 28 | fn test_parenthesis() { 29 | new_ucmd!() 30 | .args(&["(", "1", "+", "1", ")", "*", "2"]) 31 | .run() 32 | .stdout_is("4\n"); 33 | } 34 | 35 | #[test] 36 | fn test_or() { 37 | new_ucmd!() 38 | .args(&["0", "|", "foo"]) 39 | .run() 40 | .stdout_is("foo\n"); 41 | 42 | new_ucmd!() 43 | .args(&["foo", "|", "bar"]) 44 | .run() 45 | .stdout_is("foo\n"); 46 | } 47 | 48 | #[test] 49 | fn test_and() { 50 | new_ucmd!() 51 | .args(&["foo", "&", "1"]) 52 | .run() 53 | .stdout_is("foo\n"); 54 | 55 | new_ucmd!().args(&["", "&", "1"]).run().stdout_is("0\n"); 56 | } 57 | -------------------------------------------------------------------------------- /tests/test_chown.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | extern crate uu_chown; 4 | pub use self::uu_chown::*; 5 | 6 | #[cfg(test)] 7 | mod test_passgrp { 8 | use super::uu_chown::entries::{gid2grp, grp2gid, uid2usr, usr2uid}; 9 | 10 | #[test] 11 | fn test_usr2uid() { 12 | assert_eq!(0, usr2uid("root").unwrap()); 13 | assert!(usr2uid("88888888").is_err()); 14 | assert!(usr2uid("auserthatdoesntexist").is_err()); 15 | } 16 | 17 | #[test] 18 | fn test_grp2gid() { 19 | if cfg!(target_os = "linux") || cfg!(target_os = "android") || cfg!(target_os = "windows") { 20 | assert_eq!(0, grp2gid("root").unwrap()) 21 | } else { 22 | assert_eq!(0, grp2gid("wheel").unwrap()); 23 | } 24 | assert!(grp2gid("88888888").is_err()); 25 | assert!(grp2gid("agroupthatdoesntexist").is_err()); 26 | } 27 | 28 | #[test] 29 | fn test_uid2usr() { 30 | assert_eq!("root", uid2usr(0).unwrap()); 31 | assert!(uid2usr(88888888).is_err()); 32 | } 33 | 34 | #[test] 35 | fn test_gid2grp() { 36 | if cfg!(target_os = "linux") || cfg!(target_os = "android") || cfg!(target_os = "windows") { 37 | assert_eq!("root", gid2grp(0).unwrap()); 38 | } else { 39 | assert_eq!("wheel", gid2grp(0).unwrap()); 40 | } 41 | assert!(gid2grp(88888888).is_err()); 42 | } 43 | } 44 | 45 | #[test] 46 | fn test_invalid_option() { 47 | new_ucmd!().arg("-w").arg("-q").arg("/").fails(); 48 | } 49 | -------------------------------------------------------------------------------- /src/uu/whoami/src/whoami.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_whoami"] 2 | 3 | /* 4 | * This file is part of the uutils coreutils package. 5 | * 6 | * (c) Jordi Boggiano 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | /* last synced with: whoami (GNU coreutils) 8.21 */ 13 | 14 | #[macro_use] 15 | extern crate clap; 16 | #[macro_use] 17 | extern crate uucore; 18 | 19 | mod platform; 20 | 21 | // force a re-build whenever Cargo.toml changes 22 | const _CARGO_TOML: &str = include_str!("../Cargo.toml"); 23 | 24 | pub fn uumain(args: Vec) -> i32 { 25 | let app = app_from_crate!(); 26 | 27 | if let Err(err) = app.get_matches_from_safe(args) { 28 | if err.kind == clap::ErrorKind::HelpDisplayed 29 | || err.kind == clap::ErrorKind::VersionDisplayed 30 | { 31 | println!("{}", err); 32 | 0 33 | } else { 34 | show_error!("{}", err); 35 | 1 36 | } 37 | } else { 38 | exec(); 39 | 40 | 0 41 | } 42 | } 43 | 44 | pub fn exec() { 45 | unsafe { 46 | match platform::getusername() { 47 | Ok(username) => println!("{}", username), 48 | Err(err) => match err.raw_os_error() { 49 | Some(0) | None => crash!(1, "failed to get username"), 50 | Some(_) => crash!(1, "failed to get username: {}", err), 51 | }, 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/test_hashsum.rs: -------------------------------------------------------------------------------- 1 | macro_rules! get_hash( 2 | ($str:expr) => ( 3 | $str.split(' ').collect::>()[0] 4 | ); 5 | ); 6 | 7 | macro_rules! test_digest { 8 | ($($id:ident $t:ident $size:expr)*) => ($( 9 | 10 | mod $id { 11 | use::common::util::*; 12 | static DIGEST_ARG: &'static str = concat!("--", stringify!($t)); 13 | static BITS_ARG: &'static str = concat!("--bits=", stringify!($size)); 14 | static EXPECTED_FILE: &'static str = concat!(stringify!($id), ".expected"); 15 | 16 | #[test] 17 | fn test_single_file() { 18 | let ts = TestScenario::new("hashsum"); 19 | assert_eq!(ts.fixtures.read(EXPECTED_FILE), 20 | get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).arg("input.txt").succeeds().no_stderr().stdout)); 21 | } 22 | 23 | #[test] 24 | fn test_stdin() { 25 | let ts = TestScenario::new("hashsum"); 26 | assert_eq!(ts.fixtures.read(EXPECTED_FILE), 27 | get_hash!(ts.ucmd().arg(DIGEST_ARG).arg(BITS_ARG).pipe_in_fixture("input.txt").succeeds().no_stderr().stdout)); 28 | } 29 | } 30 | )*) 31 | } 32 | 33 | test_digest! { 34 | md5 md5 128 35 | sha1 sha1 160 36 | sha224 sha224 224 37 | sha256 sha256 256 38 | sha384 sha384 384 39 | sha512 sha512 512 40 | sha3_224 sha3 224 41 | sha3_256 sha3 256 42 | sha3_384 sha3 384 43 | sha3_512 sha3 512 44 | shake128_256 shake128 256 45 | shake256_512 shake256 512 46 | } 47 | -------------------------------------------------------------------------------- /src/uu/tail/src/platform/windows.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Alexander Batischev 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | extern crate kernel32; 11 | extern crate winapi; 12 | 13 | use self::kernel32::{CloseHandle, OpenProcess, WaitForSingleObject}; 14 | use self::winapi::shared::minwindef::DWORD; 15 | use self::winapi::um::winbase::{WAIT_FAILED, WAIT_OBJECT_0}; 16 | use self::winapi::um::winnt::{HANDLE, SYNCHRONIZE}; 17 | 18 | pub type Pid = DWORD; 19 | 20 | pub struct ProcessChecker { 21 | dead: bool, 22 | handle: HANDLE, 23 | } 24 | 25 | impl ProcessChecker { 26 | pub fn new(process_id: self::Pid) -> ProcessChecker { 27 | #[allow(non_snake_case)] 28 | let FALSE = 0i32; 29 | let h = unsafe { OpenProcess(SYNCHRONIZE, FALSE, process_id as DWORD) }; 30 | ProcessChecker { 31 | dead: h.is_null(), 32 | handle: h, 33 | } 34 | } 35 | 36 | pub fn is_dead(&mut self) -> bool { 37 | if !self.dead { 38 | self.dead = unsafe { 39 | let status = WaitForSingleObject(self.handle, 0); 40 | status == WAIT_OBJECT_0 || status == WAIT_FAILED 41 | } 42 | } 43 | 44 | self.dead 45 | } 46 | } 47 | 48 | impl Drop for ProcessChecker { 49 | fn drop(&mut self) { 50 | unsafe { 51 | CloseHandle(self.handle); 52 | } 53 | } 54 | } 55 | 56 | pub fn supports_pid_checks(_pid: self::Pid) -> bool { 57 | true 58 | } 59 | -------------------------------------------------------------------------------- /src/uu/mktemp/src/tempdir.rs: -------------------------------------------------------------------------------- 1 | // Mainly taken from crate `tempdir` 2 | 3 | extern crate rand; 4 | use rand::distributions::Alphanumeric; 5 | use rand::{thread_rng, Rng}; 6 | 7 | use std::io::Result as IOResult; 8 | use std::io::{Error, ErrorKind}; 9 | use std::path::Path; 10 | 11 | // How many times should we (re)try finding an unused random name? It should be 12 | // enough that an attacker will run out of luck before we run out of patience. 13 | const NUM_RETRIES: u32 = 1 << 31; 14 | 15 | #[cfg(any(unix, target_os = "redox"))] 16 | fn create_dir>(path: P) -> IOResult<()> { 17 | use std::fs::DirBuilder; 18 | use std::os::unix::fs::DirBuilderExt; 19 | 20 | DirBuilder::new().mode(0o700).create(path) 21 | } 22 | 23 | #[cfg(windows)] 24 | fn create_dir>(path: P) -> IOResult<()> { 25 | ::std::fs::create_dir(path) 26 | } 27 | 28 | pub fn new_in>( 29 | tmpdir: P, 30 | prefix: &str, 31 | rand: usize, 32 | suffix: &str, 33 | ) -> IOResult { 34 | let mut rng = thread_rng(); 35 | for _ in 0..NUM_RETRIES { 36 | let rand_chars: String = rng.sample_iter(&Alphanumeric).take(rand).collect(); 37 | let leaf = format!("{}{}{}", prefix, rand_chars, suffix); 38 | let path = tmpdir.as_ref().join(&leaf); 39 | match create_dir(&path) { 40 | Ok(_) => return Ok(path.to_string_lossy().into_owned()), 41 | Err(ref e) if e.kind() == ErrorKind::AlreadyExists => {} 42 | Err(e) => return Err(e), 43 | } 44 | } 45 | 46 | Err(Error::new( 47 | ErrorKind::AlreadyExists, 48 | "too many temporary directories already exist", 49 | )) 50 | } 51 | -------------------------------------------------------------------------------- /tests/test_ptx.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn gnu_ext_disabled_roff_no_ref() { 5 | new_ucmd!() 6 | .args(&["-G", "-R", "input"]) 7 | .succeeds() 8 | .stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected"); 9 | } 10 | 11 | #[test] 12 | fn gnu_ext_disabled_roff_input_ref() { 13 | new_ucmd!() 14 | .args(&["-G", "-r", "-R", "input"]) 15 | .succeeds() 16 | .stdout_only_fixture("gnu_ext_disabled_roff_input_ref.expected"); 17 | } 18 | 19 | #[test] 20 | fn gnu_ext_disabled_roff_auto_ref() { 21 | new_ucmd!() 22 | .args(&["-G", "-A", "-R", "input"]) 23 | .succeeds() 24 | .stdout_only_fixture("gnu_ext_disabled_roff_auto_ref.expected"); 25 | } 26 | 27 | #[test] 28 | fn gnu_ext_disabled_tex_no_ref() { 29 | new_ucmd!() 30 | .args(&["-G", "-T", "-R", "input"]) 31 | .succeeds() 32 | .stdout_only_fixture("gnu_ext_disabled_tex_no_ref.expected"); 33 | } 34 | 35 | #[test] 36 | fn gnu_ext_disabled_tex_input_ref() { 37 | new_ucmd!() 38 | .args(&["-G", "-T", "-r", "-R", "input"]) 39 | .succeeds() 40 | .stdout_only_fixture("gnu_ext_disabled_tex_input_ref.expected"); 41 | } 42 | 43 | #[test] 44 | fn gnu_ext_disabled_tex_auto_ref() { 45 | new_ucmd!() 46 | .args(&["-G", "-T", "-A", "-R", "input"]) 47 | .succeeds() 48 | .stdout_only_fixture("gnu_ext_disabled_tex_auto_ref.expected"); 49 | } 50 | 51 | #[test] 52 | fn gnu_ext_disabled_ignore_and_only_file() { 53 | new_ucmd!() 54 | .args(&["-G", "-o", "only", "-i", "ignore", "input"]) 55 | .succeeds() 56 | .stdout_only_fixture("gnu_ext_disabled_ignore_and_only_file.expected"); 57 | } 58 | -------------------------------------------------------------------------------- /tests/test_mkdir.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | static TEST_DIR1: &'static str = "mkdir_test1"; 4 | static TEST_DIR2: &'static str = "mkdir_test2"; 5 | static TEST_DIR3: &'static str = "mkdir_test3"; 6 | static TEST_DIR4: &'static str = "mkdir_test4/mkdir_test4_1"; 7 | static TEST_DIR5: &'static str = "mkdir_test5/mkdir_test5_1"; 8 | static TEST_DIR6: &'static str = "mkdir_test6"; 9 | static TEST_FILE7: &'static str = "mkdir_test7"; 10 | 11 | #[test] 12 | fn test_mkdir_mkdir() { 13 | new_ucmd!().arg(TEST_DIR1).succeeds(); 14 | } 15 | 16 | #[test] 17 | fn test_mkdir_dup_dir() { 18 | let scene = TestScenario::new(util_name!()); 19 | scene.ucmd().arg(TEST_DIR2).succeeds(); 20 | scene.ucmd().arg(TEST_DIR2).fails(); 21 | } 22 | 23 | #[test] 24 | fn test_mkdir_mode() { 25 | new_ucmd!().arg("-m").arg("755").arg(TEST_DIR3).succeeds(); 26 | } 27 | 28 | #[test] 29 | fn test_mkdir_parent() { 30 | let scene = TestScenario::new(util_name!()); 31 | scene.ucmd().arg("-p").arg(TEST_DIR4).succeeds(); 32 | scene.ucmd().arg("-p").arg(TEST_DIR4).succeeds(); 33 | } 34 | 35 | #[test] 36 | fn test_mkdir_no_parent() { 37 | new_ucmd!().arg(TEST_DIR5).fails(); 38 | } 39 | 40 | #[test] 41 | fn test_mkdir_dup_dir_parent() { 42 | let scene = TestScenario::new(util_name!()); 43 | scene.ucmd().arg(TEST_DIR6).succeeds(); 44 | scene.ucmd().arg("-p").arg(TEST_DIR6).succeeds(); 45 | } 46 | 47 | #[test] 48 | fn test_mkdir_dup_file() { 49 | let scene = TestScenario::new(util_name!()); 50 | scene.fixtures.touch(TEST_FILE7); 51 | scene.ucmd().arg(TEST_FILE7).fails(); 52 | 53 | // mkdir should fail for a file even if -p is specified. 54 | scene.ucmd().arg("-p").arg(TEST_FILE7).fails(); 55 | } 56 | -------------------------------------------------------------------------------- /src/uu/cut/src/searcher.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Rolf Morel 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #[derive(Clone)] 11 | pub struct Searcher<'a> { 12 | haystack: &'a [u8], 13 | needle: &'a [u8], 14 | position: usize, 15 | } 16 | 17 | impl<'a> Searcher<'a> { 18 | pub fn new(haystack: &'a [u8], needle: &'a [u8]) -> Searcher<'a> { 19 | Searcher { 20 | haystack, 21 | needle, 22 | position: 0, 23 | } 24 | } 25 | } 26 | 27 | impl<'a> Iterator for Searcher<'a> { 28 | type Item = (usize, usize); 29 | 30 | fn next(&mut self) -> Option<(usize, usize)> { 31 | if self.needle.len() == 1 { 32 | for offset in self.position..self.haystack.len() { 33 | if self.haystack[offset] == self.needle[0] { 34 | self.position = offset + 1; 35 | return Some((offset, offset + 1)); 36 | } 37 | } 38 | 39 | self.position = self.haystack.len(); 40 | return None; 41 | } 42 | 43 | while self.position + self.needle.len() <= self.haystack.len() { 44 | if &self.haystack[self.position..self.position + self.needle.len()] == self.needle { 45 | let match_pos = self.position; 46 | self.position += self.needle.len(); 47 | return Some((match_pos, match_pos + self.needle.len())); 48 | } else { 49 | self.position += 1; 50 | } 51 | } 52 | None 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/common/macros.rs: -------------------------------------------------------------------------------- 1 | #[macro_export] 2 | macro_rules! assert_empty_stderr( 3 | ($cond:expr) => ( 4 | if $cond.stderr.len() > 0 { 5 | panic!(format!("stderr: {}", $cond.stderr)) 6 | } 7 | ); 8 | ); 9 | 10 | #[macro_export] 11 | macro_rules! assert_empty_stdout( 12 | ($cond:expr) => ( 13 | if $cond.stdout.len() > 0 { 14 | panic!(format!("stdout: {}", $cond.stdout)) 15 | } 16 | ); 17 | ); 18 | 19 | #[macro_export] 20 | macro_rules! assert_no_error( 21 | ($cond:expr) => ( 22 | assert!($cond.success); 23 | if $cond.stderr.len() > 0 { 24 | panic!(format!("stderr: {}", $cond.stderr)) 25 | } 26 | ); 27 | ); 28 | 29 | #[macro_export] 30 | macro_rules! path_concat { 31 | ($e:expr, ..$n:expr) => {{ 32 | use std::path::PathBuf; 33 | let n = $n; 34 | let mut pb = PathBuf::new(); 35 | for _ in 0..n { 36 | pb.push($e); 37 | } 38 | pb.to_str().unwrap().to_owned() 39 | }}; 40 | ($($e:expr),*) => {{ 41 | use std::path::PathBuf; 42 | let mut pb = PathBuf::new(); 43 | $( 44 | pb.push($e); 45 | )* 46 | pb.to_str().unwrap().to_owned() 47 | }}; 48 | } 49 | 50 | #[macro_export] 51 | macro_rules! util_name { 52 | () => { 53 | module_path!().split("_").nth(1).expect("no test name") 54 | }; 55 | } 56 | 57 | #[macro_export] 58 | macro_rules! new_ucmd { 59 | () => { 60 | TestScenario::new(util_name!()).ucmd() 61 | }; 62 | } 63 | 64 | #[macro_export] 65 | macro_rules! at_and_ucmd { 66 | () => {{ 67 | let ts = TestScenario::new(util_name!()); 68 | (ts.fixtures.clone(), ts.ucmd()) 69 | }}; 70 | } 71 | -------------------------------------------------------------------------------- /tests/test_wc.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | #[test] 4 | fn test_stdin_default() { 5 | new_ucmd!() 6 | .pipe_in_fixture("lorem_ipsum.txt") 7 | .run() 8 | .stdout_is(" 13 109 772\n"); 9 | } 10 | 11 | #[test] 12 | fn test_stdin_only_bytes() { 13 | new_ucmd!() 14 | .args(&["-c"]) 15 | .pipe_in_fixture("lorem_ipsum.txt") 16 | .run() 17 | .stdout_is(" 772\n"); 18 | } 19 | 20 | #[test] 21 | fn test_stdin_all_counts() { 22 | new_ucmd!() 23 | .args(&["-c", "-m", "-l", "-L", "-w"]) 24 | .pipe_in_fixture("alice_in_wonderland.txt") 25 | .run() 26 | .stdout_is(" 5 57 302 302 66\n"); 27 | } 28 | 29 | #[test] 30 | fn test_single_default() { 31 | new_ucmd!() 32 | .arg("moby_dick.txt") 33 | .run() 34 | .stdout_is(" 18 204 1115 moby_dick.txt\n"); 35 | } 36 | 37 | #[test] 38 | fn test_single_only_lines() { 39 | new_ucmd!() 40 | .args(&["-l", "moby_dick.txt"]) 41 | .run() 42 | .stdout_is(" 18 moby_dick.txt\n"); 43 | } 44 | 45 | #[test] 46 | fn test_single_all_counts() { 47 | new_ucmd!() 48 | .args(&["-c", "-l", "-L", "-m", "-w", "alice_in_wonderland.txt"]) 49 | .run() 50 | .stdout_is(" 5 57 302 302 66 alice_in_wonderland.txt\n"); 51 | } 52 | 53 | #[test] 54 | fn test_multiple_default() { 55 | new_ucmd!() 56 | .args(&[ 57 | "lorem_ipsum.txt", 58 | "moby_dick.txt", 59 | "alice_in_wonderland.txt", 60 | ]) 61 | .run() 62 | .stdout_is( 63 | " 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 5 57 302 \ 64 | alice_in_wonderland.txt\n 36 370 2189 total\n", 65 | ); 66 | } 67 | -------------------------------------------------------------------------------- /src/uu/od/src/formatteriteminfo.rs: -------------------------------------------------------------------------------- 1 | use std::fmt; 2 | 3 | #[derive(Copy)] 4 | pub enum FormatWriter { 5 | IntWriter(fn(u64) -> String), 6 | FloatWriter(fn(f64) -> String), 7 | MultibyteWriter(fn(&[u8]) -> String), 8 | } 9 | 10 | impl Clone for FormatWriter { 11 | #[inline] 12 | fn clone(&self) -> Self { 13 | *self 14 | } 15 | } 16 | 17 | impl PartialEq for FormatWriter { 18 | fn eq(&self, other: &FormatWriter) -> bool { 19 | use formatteriteminfo::FormatWriter::*; 20 | 21 | match (self, other) { 22 | (&IntWriter(ref a), &IntWriter(ref b)) => a == b, 23 | (&FloatWriter(ref a), &FloatWriter(ref b)) => a == b, 24 | (&MultibyteWriter(ref a), &MultibyteWriter(ref b)) => *a as usize == *b as usize, 25 | _ => false, 26 | } 27 | } 28 | } 29 | 30 | impl Eq for FormatWriter {} 31 | 32 | impl fmt::Debug for FormatWriter { 33 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 34 | match *self { 35 | FormatWriter::IntWriter(ref p) => { 36 | f.write_str("IntWriter:")?; 37 | fmt::Pointer::fmt(p, f) 38 | } 39 | FormatWriter::FloatWriter(ref p) => { 40 | f.write_str("FloatWriter:")?; 41 | fmt::Pointer::fmt(p, f) 42 | } 43 | FormatWriter::MultibyteWriter(ref p) => { 44 | f.write_str("MultibyteWriter:")?; 45 | fmt::Pointer::fmt(&(*p as *const ()), f) 46 | } 47 | } 48 | } 49 | } 50 | 51 | #[derive(Copy, Clone, PartialEq, Eq, Debug)] 52 | pub struct FormatterItemInfo { 53 | pub byte_size: usize, 54 | pub print_width: usize, // including a space in front of the text 55 | pub formatter: FormatWriter, 56 | } 57 | -------------------------------------------------------------------------------- /src/uu/od/src/byteorder_io.rs: -------------------------------------------------------------------------------- 1 | // workaround until https://github.com/BurntSushi/byteorder/issues/41 has been fixed 2 | // based on: https://github.com/netvl/immeta/blob/4460ee/src/utils.rs#L76 3 | 4 | use byteorder::ByteOrder as ByteOrderTrait; 5 | use byteorder::{BigEndian, LittleEndian, NativeEndian}; 6 | 7 | #[derive(Copy, Clone, Debug, Eq, PartialEq)] 8 | pub enum ByteOrder { 9 | Little, 10 | Big, 11 | Native, 12 | } 13 | 14 | macro_rules! gen_byte_order_ops { 15 | ($($read_name:ident, $write_name:ident -> $tpe:ty),+) => { 16 | impl ByteOrder { 17 | $( 18 | #[allow(dead_code)] 19 | #[inline] 20 | pub fn $read_name(self, source: &[u8]) -> $tpe { 21 | match self { 22 | ByteOrder::Little => LittleEndian::$read_name(source), 23 | ByteOrder::Big => BigEndian::$read_name(source), 24 | ByteOrder::Native => NativeEndian::$read_name(source), 25 | } 26 | } 27 | 28 | #[allow(dead_code)] 29 | pub fn $write_name(self, target: &mut [u8], n: $tpe) { 30 | match self { 31 | ByteOrder::Little => LittleEndian::$write_name(target, n), 32 | ByteOrder::Big => BigEndian::$write_name(target, n), 33 | ByteOrder::Native => NativeEndian::$write_name(target, n), 34 | } 35 | } 36 | )+ 37 | } 38 | } 39 | } 40 | 41 | gen_byte_order_ops! { 42 | read_u16, write_u16 -> u16, 43 | read_u32, write_u32 -> u32, 44 | read_u64, write_u64 -> u64, 45 | read_i16, write_i16 -> i16, 46 | read_i32, write_i32 -> i32, 47 | read_i64, write_i64 -> i64, 48 | read_f32, write_f32 -> f32, 49 | read_f64, write_f64 -> f64 50 | } 51 | -------------------------------------------------------------------------------- /src/uu/printf/src/tokenize/num_format/formatters/base_conv/tests.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | use super::*; 3 | 4 | #[test] 5 | fn test_arrnum_int_mult() { 6 | // (in base 10) 12 * 4 = 48 7 | let factor: Vec = vec![1, 2]; 8 | let base_num = 10; 9 | let base_ten_int_fact: u8 = 4; 10 | let should_output: Vec = vec![4, 8]; 11 | 12 | let product = arrnum_int_mult(&factor, base_num, base_ten_int_fact); 13 | assert!(product == should_output); 14 | } 15 | 16 | #[test] 17 | fn test_arrnum_int_non_base_10() { 18 | // (in base 3) 19 | // 5 * 4 = 20 20 | let factor: Vec = vec![1, 2]; 21 | let base_num = 3; 22 | let base_ten_int_fact: u8 = 4; 23 | let should_output: Vec = vec![2, 0, 2]; 24 | 25 | let product = arrnum_int_mult(&factor, base_num, base_ten_int_fact); 26 | assert!(product == should_output); 27 | } 28 | 29 | #[test] 30 | fn test_arrnum_int_div_shortcircuit() { 31 | // ( 32 | let arrnum: Vec = vec![5, 5, 5, 5, 0]; 33 | let base_num = 10; 34 | let base_ten_int_divisor: u8 = 41; 35 | let remainder_passed_in = Remainder { 36 | position: 1, 37 | replace: vec![1, 3], 38 | arr_num: &arrnum, 39 | }; 40 | 41 | // the "replace" should mean the number being divided 42 | // is 1350, the first time you can get 41 to go into 43 | // 1350, its at 135, where you can get a quotient of 44 | // 3 and a remainder of 12; 45 | 46 | let quotient_should_be: u8 = 3; 47 | let remainder_position_should_be: usize = 3; 48 | let remainder_replace_should_be = vec![1, 2]; 49 | 50 | let result = arrnum_int_div_step(remainder_passed_in, base_num, base_ten_int_divisor, false); 51 | assert!(quotient_should_be == result.quotient); 52 | assert!(remainder_position_should_be == result.remainder.position); 53 | assert!(remainder_replace_should_be == result.remainder.replace); 54 | } 55 | -------------------------------------------------------------------------------- /tests/test_head.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | static INPUT: &'static str = "lorem_ipsum.txt"; 4 | 5 | #[test] 6 | fn test_stdin_default() { 7 | new_ucmd!() 8 | .pipe_in_fixture(INPUT) 9 | .run() 10 | .stdout_is_fixture("lorem_ipsum_default.expected"); 11 | } 12 | 13 | #[test] 14 | fn test_stdin_1_line_obsolete() { 15 | new_ucmd!() 16 | .args(&["-1"]) 17 | .pipe_in_fixture(INPUT) 18 | .run() 19 | .stdout_is_fixture("lorem_ipsum_1_line.expected"); 20 | } 21 | 22 | #[test] 23 | fn test_stdin_1_line() { 24 | new_ucmd!() 25 | .args(&["-n", "1"]) 26 | .pipe_in_fixture(INPUT) 27 | .run() 28 | .stdout_is_fixture("lorem_ipsum_1_line.expected"); 29 | } 30 | 31 | #[test] 32 | fn test_stdin_5_chars() { 33 | new_ucmd!() 34 | .args(&["-c", "5"]) 35 | .pipe_in_fixture(INPUT) 36 | .run() 37 | .stdout_is_fixture("lorem_ipsum_5_chars.expected"); 38 | } 39 | 40 | #[test] 41 | fn test_single_default() { 42 | new_ucmd!() 43 | .arg(INPUT) 44 | .run() 45 | .stdout_is_fixture("lorem_ipsum_default.expected"); 46 | } 47 | 48 | #[test] 49 | fn test_single_1_line_obsolete() { 50 | new_ucmd!() 51 | .args(&["-1", INPUT]) 52 | .run() 53 | .stdout_is_fixture("lorem_ipsum_1_line.expected"); 54 | } 55 | 56 | #[test] 57 | fn test_single_1_line() { 58 | new_ucmd!() 59 | .args(&["-n", "1", INPUT]) 60 | .run() 61 | .stdout_is_fixture("lorem_ipsum_1_line.expected"); 62 | } 63 | 64 | #[test] 65 | fn test_single_5_chars() { 66 | new_ucmd!() 67 | .args(&["-c", "5", INPUT]) 68 | .run() 69 | .stdout_is_fixture("lorem_ipsum_5_chars.expected"); 70 | } 71 | 72 | #[test] 73 | fn test_verbose() { 74 | new_ucmd!() 75 | .args(&["-v", INPUT]) 76 | .run() 77 | .stdout_is_fixture("lorem_ipsum_verbose.expected"); 78 | } 79 | -------------------------------------------------------------------------------- /tests/test_readlink.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | static GIBBERISH: &'static str = "supercalifragilisticexpialidocious"; 4 | 5 | #[test] 6 | fn test_canonicalize() { 7 | let (at, mut ucmd) = at_and_ucmd!(); 8 | let actual = ucmd.arg("-f").arg(".").run().stdout; 9 | let expect = at.root_dir_resolved() + "\n"; 10 | println!("actual: {:?}", actual); 11 | println!("expect: {:?}", expect); 12 | assert_eq!(actual, expect); 13 | } 14 | 15 | #[test] 16 | fn test_canonicalize_existing() { 17 | let (at, mut ucmd) = at_and_ucmd!(); 18 | let actual = ucmd.arg("-e").arg(".").run().stdout; 19 | let expect = at.root_dir_resolved() + "\n"; 20 | println!("actual: {:?}", actual); 21 | println!("expect: {:?}", expect); 22 | assert_eq!(actual, expect); 23 | } 24 | 25 | #[test] 26 | fn test_canonicalize_missing() { 27 | let (at, mut ucmd) = at_and_ucmd!(); 28 | let actual = ucmd.arg("-m").arg(GIBBERISH).run().stdout; 29 | let expect = path_concat!(at.root_dir_resolved(), GIBBERISH) + "\n"; 30 | println!("actual: {:?}", actual); 31 | println!("expect: {:?}", expect); 32 | assert_eq!(actual, expect); 33 | } 34 | 35 | #[test] 36 | fn test_long_redirection_to_current_dir() { 37 | let (at, mut ucmd) = at_and_ucmd!(); 38 | // Create a 256-character path to current directory 39 | let dir = path_concat!(".", ..128); 40 | let actual = ucmd.arg("-n").arg("-m").arg(dir).run().stdout; 41 | let expect = at.root_dir_resolved(); 42 | println!("actual: {:?}", actual); 43 | println!("expect: {:?}", expect); 44 | assert_eq!(actual, expect); 45 | } 46 | 47 | #[test] 48 | fn test_long_redirection_to_root() { 49 | // Create a 255-character path to root 50 | let dir = path_concat!("..", ..85); 51 | let actual = new_ucmd!().arg("-n").arg("-m").arg(dir).run().stdout; 52 | let expect = get_root_path(); 53 | println!("actual: {:?}", actual); 54 | println!("expect: {:?}", expect); 55 | assert_eq!(actual, expect); 56 | } 57 | -------------------------------------------------------------------------------- /util/show-codecov.BAT: -------------------------------------------------------------------------------- 1 | @setLocal 2 | @echo off 3 | 4 | @rem ::# spell-checker:ignore (abbrevs/acronyms) gcno 5 | @rem ::# spell-checker:ignore (CMD) COMSPEC ERRORLEVEL 6 | @rem ::# spell-checker:ignore (jargon) toolchain 7 | @rem ::# spell-checker:ignore (rust) Ccodegen Cinline Coverflow RUSTC RUSTFLAGS RUSTUP 8 | @rem ::# spell-checker:ignore (utils) genhtml grcov lcov sccache uutils 9 | 10 | set BIN=uutils 11 | 12 | set "FEATURES_OPTION=--features windows" 13 | 14 | cd "%~dp0.." 15 | call echo [ "%CD%" ] 16 | 17 | call cargo clean 18 | 19 | set CARGO_INCREMENTAL=0 20 | set "RUSTC_WRAPPER=" &@REM ## NOTE: RUSTC_WRAPPER=='sccache' breaks code coverage calculations (uu_*.gcno files are not created during build) 21 | set "RUSTFLAGS=-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads" 22 | set RUSTUP_TOOLCHAIN=nightly-x86_64-pc-windows-gnu 23 | call cargo build %FEATURES_OPTION% 24 | call cargo test --no-run %FEATURES_OPTION% 25 | call cargo test --quiet %FEATURES_OPTION% 26 | 27 | set COVERAGE_REPORT_DIR=target\debug\coverage-win 28 | call rm -r "%COVERAGE_REPORT_DIR%" 2>NUL 29 | 30 | set GRCOV_IGNORE_OPTION=--ignore build.rs --ignore "/*" --ignore "[A-Za-z]:/*" 31 | @rem ::# * build LCOV coverage file 32 | call grcov . --output-type lcov --output-file "%COVERAGE_REPORT_DIR%/../lcov.info" --branch %GRCOV_IGNORE_OPTION% 33 | @rem ::# * build HTML 34 | @rem ::# -- use `genhtml` if available for display of additional branch coverage information 35 | call genhtml --version 2>NUL 1>&2 36 | if NOT ERRORLEVEL 1 ( 37 | call genhtml target/debug/lcov.info --output-directory "%COVERAGE_REPORT_DIR%" --branch-coverage --function-coverage 38 | ) else ( 39 | call grcov . --output-type html --output-file "%COVERAGE_REPORT_DIR%" --branch %GRCOV_IGNORE_OPTION% 40 | ) 41 | if ERRORLEVEL 1 goto _undefined_ 2>NUL || @for %%G in ("%COMSPEC%") do @title %%nG & @"%COMSPEC%" /d/c exit %ERRORLEVEL% 42 | 43 | call start "" "%COVERAGE_REPORT_DIR%"\index.html 44 | -------------------------------------------------------------------------------- /src/uu/dirname/src/dirname.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_dirname"] 2 | 3 | /* 4 | * This file is part of the uutils coreutils package. 5 | * 6 | * (c) Derek Chiang 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | #[macro_use] 13 | extern crate uucore; 14 | 15 | use std::path::Path; 16 | 17 | static NAME: &str = "dirname"; 18 | static SYNTAX: &str = "[OPTION] NAME..."; 19 | static SUMMARY: &str = "strip last component from file name"; 20 | static LONG_HELP: &str = " 21 | Output each NAME with its last non-slash component and trailing slashes 22 | removed; if NAME contains no /'s, output '.' (meaning the current 23 | directory). 24 | "; 25 | 26 | pub fn uumain(args: Vec) -> i32 { 27 | let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) 28 | .optflag("z", "zero", "separate output with NUL rather than newline") 29 | .parse(args); 30 | 31 | let separator = if matches.opt_present("zero") { 32 | "\0" 33 | } else { 34 | "\n" 35 | }; 36 | 37 | if !matches.free.is_empty() { 38 | for path in &matches.free { 39 | let p = Path::new(path); 40 | match p.parent() { 41 | Some(d) => { 42 | if d.components().next() == None { 43 | print!(".") 44 | } else { 45 | print!("{}", d.to_string_lossy()); 46 | } 47 | } 48 | None => { 49 | if p.is_absolute() || path == "/" { 50 | print!("/"); 51 | } else { 52 | print!("."); 53 | } 54 | } 55 | } 56 | print!("{}", separator); 57 | } 58 | } else { 59 | println!("{0}: missing operand", NAME); 60 | println!("Try '{0} --help' for more information.", NAME); 61 | return 1; 62 | } 63 | 64 | 0 65 | } 66 | -------------------------------------------------------------------------------- /src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate cpp; 3 | extern crate libc; 4 | 5 | #[macro_use] 6 | extern crate uucore; 7 | 8 | use libc::{c_char, c_int, size_t, FILE, _IOFBF, _IOLBF, _IONBF}; 9 | use std::env; 10 | use std::ptr; 11 | 12 | cpp! {{ 13 | #include 14 | 15 | extern "C" { 16 | void __stdbuf(void); 17 | 18 | void __attribute((constructor)) 19 | __stdbuf_init(void) { 20 | __stdbuf(); 21 | } 22 | 23 | FILE *__stdbuf_get_stdin() { return stdin; } 24 | FILE *__stdbuf_get_stdout() { return stdout; } 25 | FILE *__stdbuf_get_stderr() { return stderr; } 26 | } 27 | }} 28 | 29 | extern "C" { 30 | fn __stdbuf_get_stdin() -> *mut FILE; 31 | fn __stdbuf_get_stdout() -> *mut FILE; 32 | fn __stdbuf_get_stderr() -> *mut FILE; 33 | } 34 | 35 | fn set_buffer(stream: *mut FILE, value: &str) { 36 | let (mode, size): (c_int, size_t) = match value { 37 | "0" => (_IONBF, 0 as size_t), 38 | "L" => (_IOLBF, 0 as size_t), 39 | input => { 40 | let buff_size: usize = match input.parse() { 41 | Ok(num) => num, 42 | Err(e) => crash!(1, "incorrect size of buffer!: {}", e), 43 | }; 44 | (_IOFBF, buff_size as size_t) 45 | } 46 | }; 47 | let res: c_int; 48 | unsafe { 49 | let buffer: *mut c_char = ptr::null_mut(); 50 | assert!(buffer.is_null()); 51 | res = libc::setvbuf(stream, buffer, mode, size); 52 | } 53 | if res != 0 { 54 | crash!(res, "error while calling setvbuf!"); 55 | } 56 | } 57 | 58 | /// # Safety 59 | /// ToDO ... (safety note) 60 | #[no_mangle] 61 | pub unsafe extern "C" fn __stdbuf() { 62 | if let Ok(val) = env::var("_STDBUF_E") { 63 | set_buffer(__stdbuf_get_stderr(), &val); 64 | } 65 | if let Ok(val) = env::var("_STDBUF_I") { 66 | set_buffer(__stdbuf_get_stdin(), &val); 67 | } 68 | if let Ok(val) = env::var("_STDBUF_O") { 69 | set_buffer(__stdbuf_get_stdout(), &val); 70 | } 71 | } 72 | --------------------------------------------------------------------------------