├── src ├── cut │ ├── .gitignore │ ├── main.rs │ ├── Cargo.toml │ └── searcher.rs ├── printf │ ├── mod.rs │ ├── tokenize │ │ ├── mod.rs │ │ ├── num_format │ │ │ ├── mod.rs │ │ │ ├── formatters │ │ │ │ ├── mod.rs │ │ │ │ ├── floatf.rs │ │ │ │ ├── scif.rs │ │ │ │ └── base_conv │ │ │ │ │ └── tests.rs │ │ │ └── format_field.rs │ │ └── token.rs │ ├── main.rs │ ├── Cargo.toml │ └── cli.rs ├── stdbuf │ ├── libstdbuf.h │ ├── libstdbuf.c │ ├── main.rs │ ├── Cargo.toml │ └── libstdbuf.rs ├── cp │ ├── main.rs │ └── Cargo.toml ├── du │ ├── main.rs │ └── Cargo.toml ├── id │ ├── main.rs │ └── Cargo.toml ├── ln │ ├── main.rs │ └── Cargo.toml ├── ls │ ├── main.rs │ └── Cargo.toml ├── mv │ ├── main.rs │ └── Cargo.toml ├── nl │ ├── main.rs │ └── Cargo.toml ├── od │ ├── main.rs │ ├── Cargo.toml │ ├── byteorder_io.rs │ └── formatteriteminfo.rs ├── rm │ ├── main.rs │ └── Cargo.toml ├── tr │ ├── main.rs │ └── Cargo.toml ├── wc │ ├── main.rs │ └── Cargo.toml ├── arch │ ├── main.rs │ ├── Cargo.toml │ └── arch.rs ├── cat │ ├── main.rs │ └── Cargo.toml ├── comm │ ├── main.rs │ └── Cargo.toml ├── date │ ├── main.rs │ └── Cargo.toml ├── echo │ ├── main.rs │ └── Cargo.toml ├── env │ ├── main.rs │ └── Cargo.toml ├── expr │ ├── main.rs │ └── Cargo.toml ├── fmt │ ├── main.rs │ └── Cargo.toml ├── fold │ ├── main.rs │ └── Cargo.toml ├── head │ ├── main.rs │ └── Cargo.toml ├── kill │ ├── main.rs │ └── Cargo.toml ├── link │ ├── main.rs │ ├── Cargo.toml │ └── link.rs ├── more │ ├── main.rs │ └── Cargo.toml ├── nice │ ├── main.rs │ └── Cargo.toml ├── ptx │ ├── main.rs │ └── Cargo.toml ├── pwd │ ├── main.rs │ ├── Cargo.toml │ └── pwd.rs ├── seq │ ├── main.rs │ └── Cargo.toml ├── shuf │ ├── main.rs │ └── Cargo.toml ├── sort │ ├── main.rs │ └── Cargo.toml ├── stat │ ├── main.rs │ └── Cargo.toml ├── sum │ ├── main.rs │ └── Cargo.toml ├── sync │ ├── main.rs │ └── Cargo.toml ├── tac │ ├── main.rs │ └── Cargo.toml ├── tail │ ├── main.rs │ ├── Cargo.toml │ ├── platform │ │ ├── mod.rs │ │ ├── unix.rs │ │ └── windows.rs │ └── README.md ├── tee │ ├── main.rs │ └── Cargo.toml ├── test │ ├── main.rs │ └── Cargo.toml ├── true │ ├── main.rs │ ├── Cargo.toml │ └── true.rs ├── tty │ ├── main.rs │ └── Cargo.toml ├── uniq │ ├── main.rs │ └── Cargo.toml ├── who │ ├── main.rs │ └── Cargo.toml ├── yes │ ├── main.rs │ ├── Cargo.toml │ └── yes.rs ├── base32 │ ├── main.rs │ └── Cargo.toml ├── base64 │ ├── main.rs │ └── Cargo.toml ├── chgrp │ ├── main.rs │ └── Cargo.toml ├── chmod │ ├── main.rs │ └── Cargo.toml ├── chown │ ├── main.rs │ └── Cargo.toml ├── chroot │ ├── main.rs │ └── Cargo.toml ├── cksum │ ├── main.rs │ ├── Cargo.toml │ └── gen_table.rs ├── expand │ ├── main.rs │ └── Cargo.toml ├── factor │ ├── main.rs │ └── Cargo.toml ├── false │ ├── main.rs │ ├── Cargo.toml │ └── false.rs ├── groups │ ├── main.rs │ ├── Cargo.toml │ └── groups.rs ├── hostid │ ├── main.rs │ ├── Cargo.toml │ └── hostid.rs ├── mkdir │ ├── main.rs │ └── Cargo.toml ├── mkfifo │ ├── main.rs │ └── Cargo.toml ├── mknod │ ├── main.rs │ └── Cargo.toml ├── mktemp │ ├── main.rs │ ├── Cargo.toml │ └── tempdir.rs ├── nohup │ ├── main.rs │ └── Cargo.toml ├── nproc │ ├── main.rs │ └── Cargo.toml ├── paste │ ├── main.rs │ └── Cargo.toml ├── pinky │ ├── main.rs │ └── Cargo.toml ├── rmdir │ ├── main.rs │ └── Cargo.toml ├── shred │ ├── main.rs │ └── Cargo.toml ├── sleep │ ├── main.rs │ └── Cargo.toml ├── split │ ├── main.rs │ ├── Cargo.toml │ └── README.md ├── touch │ ├── main.rs │ └── Cargo.toml ├── tsort │ ├── main.rs │ └── Cargo.toml ├── uname │ ├── main.rs │ └── Cargo.toml ├── unlink │ ├── main.rs │ └── Cargo.toml ├── uptime │ ├── main.rs │ └── Cargo.toml ├── users │ ├── main.rs │ └── Cargo.toml ├── whoami │ ├── main.rs │ ├── Cargo.toml │ ├── platform │ │ ├── mod.rs │ │ ├── unix.rs │ │ └── windows.rs │ └── whoami.rs ├── dirname │ ├── main.rs │ └── Cargo.toml ├── hashsum │ ├── main.rs │ └── Cargo.toml ├── install │ ├── main.rs │ └── Cargo.toml ├── logname │ ├── main.rs │ ├── Cargo.toml │ └── logname.rs ├── pathchk │ ├── main.rs │ └── Cargo.toml ├── relpath │ ├── main.rs │ └── Cargo.toml ├── timeout │ ├── main.rs │ └── Cargo.toml ├── basename │ ├── main.rs │ └── Cargo.toml ├── dircolors │ ├── main.rs │ └── Cargo.toml ├── hostname │ ├── main.rs │ └── Cargo.toml ├── printenv │ ├── main.rs │ └── Cargo.toml ├── readlink │ ├── main.rs │ └── Cargo.toml ├── realpath │ ├── main.rs │ └── Cargo.toml ├── truncate │ ├── main.rs │ └── Cargo.toml ├── unexpand │ ├── main.rs │ └── Cargo.toml └── uucore │ ├── Cargo.toml │ ├── lib.rs │ ├── utf8.rs │ ├── wide.rs │ ├── utsname.rs │ └── parse_time.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 │ ├── cp │ │ ├── hello_dir │ │ │ └── hello.txt │ │ ├── hello_world.txt │ │ └── hello_dir_with_file │ │ │ └── hello_world.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_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 │ │ ├── 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 │ ├── 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_tsort.rs ├── test_ls.rs ├── test_paste.rs ├── test_pathchk.rs ├── test_stdbuf.rs ├── test_cksum.rs ├── test_seq.rs ├── test_fold.rs ├── test_realpath.rs ├── test_dirname.rs ├── test_test.rs ├── test_tr.rs ├── test_truncate.rs ├── test_expr.rs ├── test_mkdir.rs ├── test_link.rs ├── test_tac.rs ├── test_sum.rs ├── test_unlink.rs ├── test_chown.rs ├── test_readlink.rs ├── test_ptx.rs ├── test_wc.rs ├── test_hashsum.rs ├── test_pinky.rs ├── test_head.rs ├── test_who.rs └── test_env.rs ├── .busybox-config ├── .gitignore ├── .travis.yml ├── LICENSE └── appveyor.yml /src/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/cp/hello_dir/hello.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /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/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/sort/numeric_floats.txt: -------------------------------------------------------------------------------- 1 | .03 2 | .02 3 | -------------------------------------------------------------------------------- /tests/fixtures/sum/bsd_single_file.expected: -------------------------------------------------------------------------------- 1 | 8109 1 2 | -------------------------------------------------------------------------------- /src/printf/mod.rs: -------------------------------------------------------------------------------- 1 | mod cli; 2 | mod memo; 3 | mod tokenize; 4 | -------------------------------------------------------------------------------- /tests/fixtures/cat/nonewline.txt: -------------------------------------------------------------------------------- 1 | text without a trailing newline -------------------------------------------------------------------------------- /tests/fixtures/comm/bad_order12.check_order.expected: -------------------------------------------------------------------------------- 1 | e 2 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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/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/head/lorem_ipsum_1_line.expected: -------------------------------------------------------------------------------- 1 | Lorem ipsum dolor sit amet, 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/cat/256.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shinh/coreutils/master/tests/fixtures/cat/256.txt -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/printf/tokenize/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod token; 2 | pub mod sub; 3 | pub mod unescaped_text; 4 | mod num_format; 5 | -------------------------------------------------------------------------------- /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/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/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 -------------------------------------------------------------------------------- /src/printf/tokenize/num_format/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod format_field; 2 | mod formatter; 3 | mod formatters; 4 | pub mod num_format; 5 | -------------------------------------------------------------------------------- /src/stdbuf/libstdbuf.h: -------------------------------------------------------------------------------- 1 | #ifndef UUTILS_LIBSTDBUF_H 2 | #define UUTILS_LIBSTDBUF_H 3 | 4 | void stdbuf(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /tests/test_false.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_exit_code() { 6 | new_ucmd!().fails(); 7 | } 8 | -------------------------------------------------------------------------------- /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/test_true.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_exit_code() { 6 | new_ucmd!().succeeds(); 7 | } 8 | -------------------------------------------------------------------------------- /src/cp/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_cp; 2 | 3 | fn main() { 4 | std::process::exit(uu_cp::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/du/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_du; 2 | 3 | fn main() { 4 | std::process::exit(uu_du::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/id/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_id; 2 | 3 | fn main() { 4 | std::process::exit(uu_id::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/ln/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_ln; 2 | 3 | fn main() { 4 | std::process::exit(uu_ln::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/ls/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_ls; 2 | 3 | fn main() { 4 | std::process::exit(uu_ls::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/mv/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_mv; 2 | 3 | fn main() { 4 | std::process::exit(uu_mv::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/nl/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_nl; 2 | 3 | fn main() { 4 | std::process::exit(uu_nl::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/od/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_od; 2 | 3 | fn main() { 4 | std::process::exit(uu_od::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/rm/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_rm; 2 | 3 | fn main() { 4 | std::process::exit(uu_rm::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/tr/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_tr; 2 | 3 | fn main() { 4 | std::process::exit(uu_tr::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/wc/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_wc; 2 | 3 | fn main() { 4 | std::process::exit(uu_wc::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha384.expected: -------------------------------------------------------------------------------- 1 | 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e -------------------------------------------------------------------------------- /tests/fixtures/hashsum/sha3_384.expected: -------------------------------------------------------------------------------- 1 | fbd0c5931195aaa9517869972b372f717bb69f7f9f72bfc0884ed0531c36a16fc2db5dd6d82131968b23ffe0e90757e5 -------------------------------------------------------------------------------- /src/arch/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_arch; 2 | 3 | fn main() { 4 | std::process::exit(uu_arch::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/cat/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_cat; 2 | 3 | fn main() { 4 | std::process::exit(uu_cat::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/comm/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_comm; 2 | 3 | fn main() { 4 | std::process::exit(uu_comm::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/cut/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_cut; 2 | 3 | fn main() { 4 | std::process::exit(uu_cut::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/date/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_echo; 2 | 3 | fn main() { 4 | std::process::exit(uu_date::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/echo/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_echo; 2 | 3 | fn main() { 4 | std::process::exit(uu_echo::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/env/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_env; 2 | 3 | fn main() { 4 | std::process::exit(uu_env::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/expr/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_expr; 2 | 3 | fn main() { 4 | std::process::exit(uu_expr::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/fmt/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_fmt; 2 | 3 | fn main() { 4 | std::process::exit(uu_fmt::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/fold/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_fold; 2 | 3 | fn main() { 4 | std::process::exit(uu_fold::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/head/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_head; 2 | 3 | fn main() { 4 | std::process::exit(uu_head::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/kill/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_kill; 2 | 3 | fn main() { 4 | std::process::exit(uu_kill::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/link/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_link; 2 | 3 | fn main() { 4 | std::process::exit(uu_link::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/more/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_more; 2 | 3 | fn main() { 4 | std::process::exit(uu_more::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/nice/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_nice; 2 | 3 | fn main() { 4 | std::process::exit(uu_nice::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/ptx/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_ptx; 2 | 3 | fn main() { 4 | std::process::exit(uu_ptx::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/pwd/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_pwd; 2 | 3 | fn main() { 4 | std::process::exit(uu_pwd::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/seq/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_seq; 2 | 3 | fn main() { 4 | std::process::exit(uu_seq::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/shuf/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_shuf; 2 | 3 | fn main() { 4 | std::process::exit(uu_shuf::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/sort/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_sort; 2 | 3 | fn main() { 4 | std::process::exit(uu_sort::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/stat/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_stat; 2 | 3 | fn main() { 4 | std::process::exit(uu_stat::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/stdbuf/libstdbuf.c: -------------------------------------------------------------------------------- 1 | #include "libstdbuf.h" 2 | 3 | void __attribute ((constructor)) 4 | stdbuf_init (void) 5 | { 6 | stdbuf(); 7 | } 8 | -------------------------------------------------------------------------------- /src/sum/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_sum; 2 | 3 | fn main() { 4 | std::process::exit(uu_sum::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/sync/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_sync; 2 | 3 | fn main() { 4 | std::process::exit(uu_sync::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/tac/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_tac; 2 | 3 | fn main() { 4 | std::process::exit(uu_tac::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/tail/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_tail; 2 | 3 | fn main() { 4 | std::process::exit(uu_tail::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/tee/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_tee; 2 | 3 | fn main() { 4 | std::process::exit(uu_tee::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/test/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_test; 2 | 3 | fn main() { 4 | std::process::exit(uu_test::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/true/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_true; 2 | 3 | fn main() { 4 | std::process::exit(uu_true::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/tty/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_tty; 2 | 3 | fn main() { 4 | std::process::exit(uu_tty::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/uniq/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_uniq; 2 | 3 | fn main() { 4 | std::process::exit(uu_uniq::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/who/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_who; 2 | 3 | fn main() { 4 | std::process::exit(uu_who::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/yes/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_yes; 2 | 3 | fn main() { 4 | std::process::exit(uu_yes::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /tests/fixtures/ptx/gnu_ext_disabled_ignore_and_only_file.expected: -------------------------------------------------------------------------------- 1 | .xx "" """quotes"", for" "roff" "" 2 | .xx "" "{brackets} for" "tex" "" 3 | -------------------------------------------------------------------------------- /src/base32/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_base32; 2 | 3 | fn main() { 4 | std::process::exit(uu_base32::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/base64/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_base64; 2 | 3 | fn main() { 4 | std::process::exit(uu_base64::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/chgrp/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_chgrp; 2 | 3 | fn main() { 4 | std::process::exit(uu_chgrp::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/chmod/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_chmod; 2 | 3 | fn main() { 4 | std::process::exit(uu_chmod::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/chown/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_chown; 2 | 3 | fn main() { 4 | std::process::exit(uu_chown::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/chroot/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_chroot; 2 | 3 | fn main() { 4 | std::process::exit(uu_chroot::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/cksum/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_cksum; 2 | 3 | fn main() { 4 | std::process::exit(uu_cksum::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/expand/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_expand; 2 | 3 | fn main() { 4 | std::process::exit(uu_expand::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/factor/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_factor; 2 | 3 | fn main() { 4 | std::process::exit(uu_factor::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/false/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_false; 2 | 3 | fn main() { 4 | std::process::exit(uu_false::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/groups/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_groups; 2 | 3 | fn main() { 4 | std::process::exit(uu_groups::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/hostid/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_hostid; 2 | 3 | fn main() { 4 | std::process::exit(uu_hostid::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/mkdir/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_mkdir; 2 | 3 | fn main() { 4 | std::process::exit(uu_mkdir::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/mkfifo/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_mkfifo; 2 | 3 | fn main() { 4 | std::process::exit(uu_mkfifo::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/mknod/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_mknod; 2 | 3 | fn main() { 4 | std::process::exit(uu_mknod::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/mktemp/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_mktemp; 2 | 3 | fn main() { 4 | std::process::exit(uu_mktemp::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/nohup/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_nohup; 2 | 3 | fn main() { 4 | std::process::exit(uu_nohup::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/nproc/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_nproc; 2 | 3 | fn main() { 4 | std::process::exit(uu_nproc::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/paste/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_paste; 2 | 3 | fn main() { 4 | std::process::exit(uu_paste::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/pinky/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_pinky; 2 | 3 | fn main() { 4 | std::process::exit(uu_pinky::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/printf/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_printf; 2 | 3 | fn main() { 4 | std::process::exit(uu_printf::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/rmdir/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_rmdir; 2 | 3 | fn main() { 4 | std::process::exit(uu_rmdir::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/shred/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_shred; 2 | 3 | fn main() { 4 | std::process::exit(uu_shred::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/sleep/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_sleep; 2 | 3 | fn main() { 4 | std::process::exit(uu_sleep::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/split/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_split; 2 | 3 | fn main() { 4 | std::process::exit(uu_split::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/stdbuf/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_stdbuf; 2 | 3 | fn main() { 4 | std::process::exit(uu_stdbuf::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/touch/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_touch; 2 | 3 | fn main() { 4 | std::process::exit(uu_touch::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/tsort/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_tsort; 2 | 3 | fn main() { 4 | std::process::exit(uu_tsort::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/uname/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_uname; 2 | 3 | fn main() { 4 | std::process::exit(uu_uname::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/unlink/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_unlink; 2 | 3 | fn main() { 4 | std::process::exit(uu_unlink::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/uptime/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_uptime; 2 | 3 | fn main() { 4 | std::process::exit(uu_uptime::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/users/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_users; 2 | 3 | fn main() { 4 | std::process::exit(uu_users::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/whoami/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_whoami; 2 | 3 | fn main() { 4 | std::process::exit(uu_whoami::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/dirname/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_dirname; 2 | 3 | fn main() { 4 | std::process::exit(uu_dirname::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/hashsum/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_hashsum; 2 | 3 | fn main() { 4 | std::process::exit(uu_hashsum::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/install/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_install; 2 | 3 | fn main() { 4 | std::process::exit(uu_install::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/logname/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_logname; 2 | 3 | fn main() { 4 | std::process::exit(uu_logname::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/pathchk/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_pathchk; 2 | 3 | fn main() { 4 | std::process::exit(uu_pathchk::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/relpath/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_relpath; 2 | 3 | fn main() { 4 | std::process::exit(uu_relpath::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/timeout/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_timeout; 2 | 3 | fn main() { 4 | std::process::exit(uu_timeout::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /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/basename/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_basename; 2 | 3 | fn main() { 4 | std::process::exit(uu_basename::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/dircolors/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_dircolors; 2 | 3 | fn main() { 4 | std::process::exit(uu_dircolors::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/hostname/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_hostname; 2 | 3 | fn main() { 4 | std::process::exit(uu_hostname::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/printenv/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_printenv; 2 | 3 | fn main() { 4 | std::process::exit(uu_printenv::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/readlink/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_readlink; 2 | 3 | fn main() { 4 | std::process::exit(uu_readlink::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/realpath/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_realpath; 2 | 3 | fn main() { 4 | std::process::exit(uu_realpath::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/truncate/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_truncate; 2 | 3 | fn main() { 4 | std::process::exit(uu_truncate::uumain(std::env::args().collect())); 5 | } 6 | -------------------------------------------------------------------------------- /src/unexpand/main.rs: -------------------------------------------------------------------------------- 1 | extern crate uu_unexpand; 2 | 3 | fn main() { 4 | std::process::exit(uu_unexpand::uumain(std::env::args().collect())); 5 | } 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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | /src/*/gen_table 3 | /build/ 4 | /tmp/ 5 | /busybox/ 6 | /.vscode/ 7 | *~ 8 | .*.swp 9 | .*.swo 10 | .idea 11 | Cargo.lock 12 | lib*.a 13 | -------------------------------------------------------------------------------- /tests/fixtures/hashsum/shake256_512.expected: -------------------------------------------------------------------------------- 1 | 7c9896ea84a2a1b80b2183a3f2b4e43cd59b7d48471dc213bcedaccb699d6e6f7ad5d304928ab79329f1fc62f6db072d95b51209eb807683f5c9371872a2dd4e -------------------------------------------------------------------------------- /tests/fixtures/uniq/sorted-simple.expected: -------------------------------------------------------------------------------- 1 | aaaaa ⅰ 2 | bbbbb ⅱ 3 | ccccc ⅲ 4 | ddddd ⅲ 5 | eeeee ⅲ 6 | fffff ⅲ 7 | ggggg ⅲ 8 | GGGGG ⅲ 9 | -------------------------------------------------------------------------------- /tests/test_pwd.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_default() { 6 | let (at, mut ucmd) = at_and_ucmd!(); 7 | ucmd.run().stdout_is(at.root_dir_resolved()); 8 | } 9 | -------------------------------------------------------------------------------- /src/printf/tokenize/num_format/formatters/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod intf; 2 | pub mod floatf; 3 | pub mod cninetyninehexfloatf; 4 | pub mod scif; 5 | pub mod decf; 6 | mod float_common; 7 | mod base_conv; 8 | -------------------------------------------------------------------------------- /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/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/true/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "true" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_true" 8 | path = "true.rs" 9 | 10 | [[bin]] 11 | name = "true" 12 | path = "main.rs" 13 | -------------------------------------------------------------------------------- /src/false/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "false" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_false" 8 | path = "false.rs" 9 | 10 | [[bin]] 11 | name = "false" 12 | path = "main.rs" 13 | -------------------------------------------------------------------------------- /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/test_tsort.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_sort_call_graph() { 6 | new_ucmd!() 7 | .arg("call_graph.txt") 8 | .run() 9 | .stdout_is_fixture("call_graph.expected"); 10 | } 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/cut/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cut" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_cut" 8 | path = "cut.rs" 9 | 10 | [dependencies] 11 | uucore = { path="../uucore" } 12 | 13 | [[bin]] 14 | name = "cut" 15 | path = "main.rs" 16 | -------------------------------------------------------------------------------- /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_ls.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_ls_ls() { 6 | new_ucmd!().succeeds(); 7 | } 8 | 9 | #[test] 10 | fn test_ls_ls_i() { 11 | new_ucmd!().arg("-i").succeeds(); 12 | new_ucmd!().arg("-il").succeeds(); 13 | } 14 | -------------------------------------------------------------------------------- /src/echo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "echo" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_echo" 8 | path = "echo.rs" 9 | 10 | [dependencies] 11 | uucore = { path="../uucore" } 12 | 13 | [[bin]] 14 | name = "echo" 15 | path = "main.rs" 16 | -------------------------------------------------------------------------------- /src/fold/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fold" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_fold" 8 | path = "fold.rs" 9 | 10 | [dependencies] 11 | uucore = { path="../uucore" } 12 | 13 | [[bin]] 14 | name = "fold" 15 | path = "main.rs" 16 | -------------------------------------------------------------------------------- /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/test_paste.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_combine_pairs_of_lines() { 6 | new_ucmd!() 7 | .args(&["-s", "-d", "\t\n", "html_colors.txt"]) 8 | .run() 9 | .stdout_is_fixture("html_colors.expected"); 10 | } 11 | -------------------------------------------------------------------------------- /src/du/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "du" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_du" 8 | path = "du.rs" 9 | 10 | [dependencies] 11 | time = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "du" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/ln/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ln" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_ln" 8 | path = "ln.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "ln" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /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 ⅲ -------------------------------------------------------------------------------- /src/base64/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "base64" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_base64" 8 | path = "base64.rs" 9 | 10 | [dependencies] 11 | uucore = { path="../uucore" } 12 | 13 | [[bin]] 14 | name = "base64" 15 | path = "main.rs" 16 | -------------------------------------------------------------------------------- /src/env/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "env" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_env" 8 | path = "env.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "env" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/mv/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mv" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_mv" 8 | path = "mv.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "mv" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/rm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rm" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_rm" 8 | path = "rm.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "rm" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/wc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wc" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_wc" 8 | path = "wc.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "wc" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/expr/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "expr" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_expr" 8 | path = "expr.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "expr" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/head/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "head" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_head" 8 | path = "head.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "head" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/kill/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "kill" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_kill" 8 | path = "kill.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "kill" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/link/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "link" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_link" 8 | path = "link.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "link" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/pwd/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pwd" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_pwd" 8 | path = "pwd.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "pwd" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/seq/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "seq" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_seq" 8 | path = "seq.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "seq" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/sum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sum" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_sum" 8 | path = "sum.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "sum" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/tac/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tac" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_tac" 8 | path = "tac.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "tac" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "test" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_test" 8 | path = "test.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "test" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/yes/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "yes" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_yes" 8 | path = "yes.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "yes" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/basename/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basename" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_basename" 8 | path = "basename.rs" 9 | 10 | [dependencies] 11 | uucore = { path="../uucore" } 12 | 13 | [[bin]] 14 | name = "basename" 15 | path = "main.rs" 16 | -------------------------------------------------------------------------------- /src/cksum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cksum" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_cksum" 8 | path = "cksum.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "cksum" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/cp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cp" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_cp" 8 | path = "cp.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "cp" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/factor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "factor" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_factor" 8 | path = "factor.rs" 9 | 10 | [dependencies] 11 | rand = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "factor" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/hostid/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hostid" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_hostid" 8 | path = "hostid.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "hostid" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/paste/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "paste" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_paste" 8 | path = "paste.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "paste" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/rmdir/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rmdir" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_rmdir" 8 | path = "rmdir.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "rmdir" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/sleep/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sleep" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_sleep" 8 | path = "sleep.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "sleep" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/split/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "split" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_split" 8 | path = "split.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "split" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/tsort/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tsort" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_tsort" 8 | path = "tsort.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "tsort" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/dirname/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dirname" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_dirname" 8 | path = "dirname.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "dirname" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/logname/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "logname" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_logname" 8 | path = "logname.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "logname" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/stdbuf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "stdbuf" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_stdbuf" 8 | path = "stdbuf.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "stdbuf" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/tee/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tee" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_tee" 8 | path = "tee.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "tee" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/tty/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tty" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_tty" 8 | path = "tty.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "tty" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/comm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "comm" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_comm" 8 | path = "comm.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | getopts = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "comm" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/date/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "date" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_date" 8 | path = "date.rs" 9 | 10 | [dependencies] 11 | chrono = "*" 12 | clap = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "date" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/fmt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fmt" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_fmt" 8 | path = "fmt.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | unicode-width = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "fmt" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/hostname/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hostname" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_hostname" 8 | path = "hostname.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "hostname" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/nice/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nice" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_nice" 8 | path = "nice.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "nice" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/relpath/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "relpath" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_relpath" 8 | path = "relpath.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "relpath" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/shuf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "shuf" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_shuf" 8 | path = "shuf.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | rand = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "shuf" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /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/chmod/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chmod" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_chmod" 8 | path = "chmod.rs" 9 | 10 | [dependencies] 11 | libc = "*" 12 | uucore = { path="../uucore" } 13 | walker = "*" 14 | 15 | [[bin]] 16 | name = "chmod" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/dircolors/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dircolors" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_dircolors" 8 | path = "dircolors.rs" 9 | 10 | [dependencies] 11 | glob = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "dircolors" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/mkdir/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mkdir" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_mkdir" 8 | path = "mkdir.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "mkdir" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/nohup/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nohup" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_nohup" 8 | path = "nohup.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "nohup" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/printenv/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "printenv" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_printenv" 8 | path = "printenv.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "printenv" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/realpath/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "realpath" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_realpath" 8 | path = "realpath.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "realpath" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/truncate/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "truncate" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_truncate" 8 | path = "truncate.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "truncate" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/mkfifo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mkfifo" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_mkfifo" 8 | path = "mkfifo.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "mkfifo" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/mknod/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mknod" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_mknod" 8 | path = "mknod.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "^0.2.4" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "mknod" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/printf/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "printf" 3 | version = "0.0.1" 4 | authors = ["Nathan Ross"] 5 | 6 | [lib] 7 | name = "uu_printf" 8 | path = "printf.rs" 9 | 10 | [dependencies] 11 | "itertools" = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [[bin]] 15 | name = "printf" 16 | path = "main.rs" 17 | -------------------------------------------------------------------------------- /src/unlink/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unlink" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_unlink" 8 | path = "unlink.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "unlink" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/pathchk/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pathchk" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_pathchk" 8 | path = "pathchk.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "pathchk" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/arch/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "arch" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_arch" 8 | path = "arch.rs" 9 | 10 | [dependencies.uucore] 11 | path = "../uucore" 12 | default-features = false 13 | features = ["utsname"] 14 | 15 | [[bin]] 16 | name = "arch" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/expand/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "expand" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_expand" 8 | path = "expand.rs" 9 | 10 | [dependencies] 11 | unicode-width = "*" 12 | getopts = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "expand" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/id/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "id" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_id" 8 | path = "id.rs" 9 | 10 | [dependencies.uucore] 11 | path = "../uucore" 12 | default-features = false 13 | features = ["entries", "process"] 14 | 15 | [[bin]] 16 | name = "id" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/readlink/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "readlink" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_readlink" 8 | path = "readlink.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "readlink" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/nproc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nproc" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_nproc" 8 | path = "nproc.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | num_cpus = "*" 14 | uucore = { path="../uucore" } 15 | 16 | [[bin]] 17 | name = "nproc" 18 | path = "main.rs" 19 | -------------------------------------------------------------------------------- /src/sort/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sort" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_sort" 8 | path = "sort.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | semver = "*" 13 | itertools = "*" 14 | uucore = { path="../uucore" } 15 | 16 | [[bin]] 17 | name = "sort" 18 | path = "main.rs" 19 | -------------------------------------------------------------------------------- /src/uname/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uname" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_uname" 8 | path = "uname.rs" 9 | 10 | [dependencies.uucore] 11 | path = "../uucore" 12 | default-features = false 13 | features = ["utsname"] 14 | 15 | [[bin]] 16 | name = "uname" 17 | path = "main.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/groups/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "groups" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_groups" 8 | path = "groups.rs" 9 | 10 | [dependencies.uucore] 11 | path = "../uucore" 12 | default-features = false 13 | features = ["entries"] 14 | 15 | [[bin]] 16 | name = "groups" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/od/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "od" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_od" 8 | path = "od.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | byteorder = "*" 14 | half = "*" 15 | uucore = { path="../uucore" } 16 | 17 | [[bin]] 18 | name = "od" 19 | path = "main.rs" 20 | -------------------------------------------------------------------------------- /src/timeout/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "timeout" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_timeout" 8 | path = "timeout.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | time = "*" 14 | uucore = { path="../uucore" } 15 | 16 | [[bin]] 17 | name = "timeout" 18 | path = "main.rs" 19 | -------------------------------------------------------------------------------- /src/unexpand/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unexpand" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_unexpand" 8 | path = "unexpand.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | unicode-width = "*" 13 | uucore = { path="../uucore" } 14 | 15 | [[bin]] 16 | name = "unexpand" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/mktemp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mktemp" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_mktemp" 8 | path = "mktemp.rs" 9 | 10 | [dependencies] 11 | uucore = { path="../uucore" } 12 | getopts = "*" 13 | rand = "0.3" 14 | tempfile = "*" 15 | 16 | [[bin]] 17 | name = "mktemp" 18 | path = "main.rs" 19 | -------------------------------------------------------------------------------- /src/pinky/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pinky" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_pinky" 8 | path = "pinky.rs" 9 | 10 | [dependencies.uucore] 11 | path = "../uucore" 12 | default-features = false 13 | features = ["utmpx", "entries"] 14 | 15 | [[bin]] 16 | name = "pinky" 17 | path = "main.rs" 18 | -------------------------------------------------------------------------------- /src/uniq/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uniq" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_uniq" 8 | path = "uniq.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | 13 | [dependencies.uucore] 14 | path="../uucore" 15 | default-features = false 16 | 17 | [[bin]] 18 | name = "uniq" 19 | path = "main.rs" 20 | -------------------------------------------------------------------------------- /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/sync/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sync" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_sync" 8 | path = "sync.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | winapi = "*" 14 | kernel32-sys = "*" 15 | uucore = { path="../uucore" } 16 | 17 | [[bin]] 18 | name = "sync" 19 | path = "main.rs" 20 | -------------------------------------------------------------------------------- /src/tail/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tail" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_tail" 8 | path = "tail.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | kernel32-sys = "*" 13 | libc = "*" 14 | winapi = "*" 15 | uucore = { path="../uucore" } 16 | 17 | [[bin]] 18 | name = "tail" 19 | path = "main.rs" 20 | -------------------------------------------------------------------------------- /src/tr/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tr" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_tr" 8 | path = "tr.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | bit-set = "*" 13 | 14 | [dependencies.uucore] 15 | path = "../uucore" 16 | default-features = false 17 | 18 | [[bin]] 19 | name = "tr" 20 | path = "main.rs" 21 | -------------------------------------------------------------------------------- /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/base32/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "base32" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_base32" 8 | path = "base32.rs" 9 | 10 | [dependencies] 11 | uucore = { path="../uucore" } 12 | 13 | [dependencies.clippy] 14 | version = "*" 15 | optional = true 16 | 17 | [[bin]] 18 | name = "base32" 19 | path = "main.rs" 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/cat/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cat" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_cat" 8 | path = "cat.rs" 9 | 10 | [dependencies] 11 | quick-error = "1.1.0" 12 | uucore = { path="../uucore" } 13 | 14 | [target.'cfg(unix)'.dependencies] 15 | unix_socket = "0.5.0" 16 | 17 | [[bin]] 18 | name = "cat" 19 | path = "main.rs" 20 | -------------------------------------------------------------------------------- /src/shred/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "shred" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_shred" 8 | path = "shred.rs" 9 | 10 | [dependencies] 11 | rand = "0.3" 12 | filetime = "*" 13 | getopts = "*" 14 | libc = "*" 15 | time = "*" 16 | uucore = { path="../uucore" } 17 | 18 | [[bin]] 19 | name = "shred" 20 | path = "main.rs" 21 | -------------------------------------------------------------------------------- /tests/test_pathchk.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_default_mode() { 6 | // test the default mode 7 | 8 | // accept some reasonable default 9 | new_ucmd!().args(&["abc/def"]).succeeds().no_stdout(); 10 | 11 | // fail on long inputs 12 | new_ucmd!().args(&[repeat_str("test", 20000)]).fails().no_stdout(); 13 | } 14 | -------------------------------------------------------------------------------- /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/users/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "users" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_users" 8 | path = "users.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | 13 | [dependencies.uucore] 14 | default-features = false 15 | features = ["utmpx"] 16 | path = "../uucore" 17 | 18 | [[bin]] 19 | name = "users" 20 | path = "main.rs" 21 | -------------------------------------------------------------------------------- /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/chgrp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chgrp" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_chgrp" 8 | path = "chgrp.rs" 9 | 10 | [dependencies] 11 | walkdir = "*" 12 | 13 | [dependencies.uucore] 14 | path = "../uucore" 15 | default-features = false 16 | features = ["entries", "fs"] 17 | 18 | [[bin]] 19 | name = "chgrp" 20 | path = "main.rs" 21 | -------------------------------------------------------------------------------- /src/chroot/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chroot" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_chroot" 8 | path = "chroot.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | 13 | [dependencies.uucore] 14 | path = "../uucore" 15 | default-features = false 16 | features = ["entries"] 17 | 18 | [[bin]] 19 | name = "chroot" 20 | path = "main.rs" 21 | -------------------------------------------------------------------------------- /src/nl/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nl" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_nl" 8 | path = "nl.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | aho-corasick = "*" 14 | memchr = "*" 15 | regex = "*" 16 | regex-syntax = "*" 17 | uucore = { path="../uucore" } 18 | 19 | [[bin]] 20 | name = "nl" 21 | path = "main.rs" 22 | -------------------------------------------------------------------------------- /src/uptime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uptime" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_uptime" 8 | path = "uptime.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | 13 | [dependencies.uucore] 14 | path = "../uucore" 15 | default-features = false 16 | features = ["utmpx"] 17 | 18 | [[bin]] 19 | name = "uptime" 20 | path = "main.rs" 21 | -------------------------------------------------------------------------------- /src/more/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "more" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_more" 8 | path = "more.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | uucore = { path="../uucore" } 13 | 14 | [target.'cfg(all(unix, not(target_os = "fuchsia")))'.dependencies] 15 | nix = "*" 16 | 17 | [[bin]] 18 | name = "more" 19 | path = "main.rs" 20 | -------------------------------------------------------------------------------- /src/ptx/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ptx" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_ptx" 8 | path = "ptx.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | aho-corasick = "*" 14 | memchr = "*" 15 | regex-syntax = "*" 16 | regex = "*" 17 | uucore = { path="../uucore" } 18 | 19 | [[bin]] 20 | name = "ptx" 21 | path = "main.rs" 22 | -------------------------------------------------------------------------------- /src/stat/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "stat" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_stat" 8 | path = "stat.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | time = "*" 13 | 14 | [dependencies.uucore] 15 | path = "../uucore" 16 | default-features = false 17 | features = ["entries"] 18 | 19 | [[bin]] 20 | name = "stat" 21 | path = "main.rs" 22 | -------------------------------------------------------------------------------- /src/who/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "who" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_who" 8 | path = "who.rs" 9 | 10 | [dependencies.uucore] 11 | path = "../uucore" 12 | default-features = false 13 | features = ["utmpx"] 14 | 15 | [dependencies.clippy] 16 | version = "*" 17 | optional = true 18 | 19 | [[bin]] 20 | name = "who" 21 | path = "main.rs" 22 | -------------------------------------------------------------------------------- /src/false/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/true/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 | -------------------------------------------------------------------------------- /src/install/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "install" 3 | version = "0.0.1" 4 | authors = ["Ben Eills "] 5 | 6 | [lib] 7 | name = "uu_install" 8 | path = "install.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = ">= 0.2" 13 | uucore = { path="../uucore" } 14 | 15 | [dev-dependencies] 16 | time = "*" 17 | 18 | [[bin]] 19 | name = "install" 20 | path = "main.rs" 21 | -------------------------------------------------------------------------------- /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/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/hashsum/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hashsum" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_hashsum" 8 | path = "hashsum.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | libc = "*" 13 | regex = "*" 14 | regex-syntax = "*" 15 | rust-crypto = "*" 16 | rustc-serialize = "*" 17 | uucore = { path="../uucore" } 18 | 19 | [[bin]] 20 | name = "hashsum" 21 | path = "main.rs" 22 | -------------------------------------------------------------------------------- /src/touch/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "touch" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_touch" 8 | path = "touch.rs" 9 | 10 | [dependencies] 11 | filetime = "*" 12 | getopts = "*" 13 | time = "*" 14 | 15 | [dependencies.uucore] 16 | path = "../uucore" 17 | default-features = false 18 | features = ["libc"] 19 | 20 | [[bin]] 21 | name = "touch" 22 | path = "main.rs" 23 | -------------------------------------------------------------------------------- /tests/test_stdbuf.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_stdbuf_unbuffered_stdout() { 6 | if cfg!(target_os="linux") { 7 | // This is a basic smoke test 8 | new_ucmd!().args(&["-o0", "head"]) 9 | .pipe_in("The quick brown fox jumps over the lazy dog.").run() 10 | .stdout_is("The quick brown fox jumps over the lazy dog."); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /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/whoami/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "whoami" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_whoami" 8 | path = "whoami.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | winapi = "*" 13 | advapi32-sys = "*" 14 | 15 | [dependencies.uucore] 16 | path = "../uucore" 17 | default-features = false 18 | features = ["entries"] 19 | 20 | [[bin]] 21 | name = "whoami" 22 | path = "main.rs" 23 | -------------------------------------------------------------------------------- /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/chown/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chown" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [lib] 7 | name = "uu_chown" 8 | path = "chown.rs" 9 | 10 | [dependencies] 11 | glob = "*" 12 | walkdir = "0.1" 13 | 14 | [dependencies.uucore] 15 | path = "../uucore" 16 | default-features = false 17 | features = ["entries", "fs"] 18 | 19 | [dependencies.clippy] 20 | version = "*" 21 | optional = true 22 | 23 | [[bin]] 24 | name = "chown" 25 | path = "main.rs" 26 | -------------------------------------------------------------------------------- /src/whoami/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/ls/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ls" 3 | version = "0.0.1" 4 | authors = ["Jeremiah Peschka "] 5 | 6 | [lib] 7 | name = "uu_ls" 8 | path = "ls.rs" 9 | 10 | [dependencies] 11 | getopts = "*" 12 | pretty-bytes = "*" 13 | term_grid = "*" 14 | termsize = "*" 15 | time = "*" 16 | lazy_static = "*" 17 | unicode-width = "*" 18 | 19 | [dependencies.uucore] 20 | path = "../uucore" 21 | default-features = false 22 | features = ["entries"] 23 | 24 | [[bin]] 25 | name = "ls" 26 | path = "main.rs" 27 | -------------------------------------------------------------------------------- /src/tail/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::{Pid, supports_pid_checks, ProcessChecker}; 12 | 13 | #[cfg(windows)] 14 | pub use self::windows::{Pid, supports_pid_checks, ProcessChecker}; 15 | 16 | #[cfg(unix)] 17 | mod unix; 18 | 19 | #[cfg(windows)] 20 | mod windows; 21 | -------------------------------------------------------------------------------- /src/whoami/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::libc::geteuid; 13 | use uucore::entries::uid2usr; 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 | -------------------------------------------------------------------------------- /tests/test_cksum.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_single_file() { 6 | new_ucmd!().arg("lorem_ipsum.txt") 7 | .succeeds().stdout_is_fixture("single_file.expected"); 8 | } 9 | 10 | #[test] 11 | fn test_multiple_files() { 12 | new_ucmd!() 13 | .arg("lorem_ipsum.txt") 14 | .arg("alice_in_wonderland.txt") 15 | .succeeds().stdout_is_fixture("multiple_files.expected"); 16 | } 17 | 18 | #[test] 19 | fn test_stdin() { 20 | new_ucmd!() 21 | .pipe_in_fixture("lorem_ipsum.txt") 22 | .succeeds().stdout_is_fixture("stdin.expected"); 23 | } 24 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | matrix: 3 | include: 4 | - rust: stable 5 | os: linux 6 | env: FEATURES='' 7 | - rust: stable 8 | os: osx 9 | env: FEATURES='' 10 | - rust: beta 11 | os: linux 12 | env: FEATURES='' 13 | - rust: beta 14 | os: osx 15 | env: FEATURES='' 16 | - rust: nightly 17 | os: linux 18 | env: FEATURES=nightly 19 | - rust: nightly 20 | os: osx 21 | env: FEATURES=nightly 22 | cache: 23 | directories: 24 | - $HOME/.cargo 25 | sudo: false 26 | script: 27 | - cargo build --features "$FEATURES" 28 | - cargo test --features "$FEATURES" --no-fail-fast 29 | -------------------------------------------------------------------------------- /tests/test_seq.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_count_up() { 6 | new_ucmd!() 7 | .args(&["10"]).run().stdout_is("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"); 8 | } 9 | 10 | #[test] 11 | fn test_count_down() { 12 | new_ucmd!() 13 | .args(&["--", "5", "-1", "1"]).run().stdout_is("5\n4\n3\n2\n1\n"); 14 | } 15 | 16 | #[test] 17 | fn test_separator_and_terminator() { 18 | new_ucmd!() 19 | .args(&["-s", ",", "-t", "!", "2", "6"]).run().stdout_is("2,3,4,5,6!"); 20 | } 21 | 22 | #[test] 23 | fn test_equalize_widths() { 24 | new_ucmd!() 25 | .args(&["-w", "5", "10"]).run().stdout_is("05\n06\n07\n08\n09\n10\n"); 26 | } 27 | -------------------------------------------------------------------------------- /tests/test_fold.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_default_80_column_wrap() { 6 | new_ucmd!() 7 | .arg("lorem_ipsum.txt") 8 | .run() 9 | .stdout_is_fixture("lorem_ipsum_80_column.expected"); 10 | } 11 | 12 | #[test] 13 | fn test_40_column_hard_cutoff() { 14 | new_ucmd!() 15 | .args(&["-w", "40", "lorem_ipsum.txt"]) 16 | .run() 17 | .stdout_is_fixture("lorem_ipsum_40_column_hard.expected"); 18 | } 19 | 20 | #[test] 21 | fn test_40_column_word_boundary() { 22 | new_ucmd!() 23 | .args(&["-s", "-w", "40", "lorem_ipsum.txt"]) 24 | .run() 25 | .stdout_is_fixture("lorem_ipsum_40_column_word.expected"); 26 | } 27 | -------------------------------------------------------------------------------- /tests/test_realpath.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_current_directory() { 6 | let (at, mut ucmd) = at_and_ucmd!(); 7 | ucmd.arg(".").run().stdout_is(at.root_dir_resolved()); 8 | } 9 | 10 | #[test] 11 | fn test_long_redirection_to_current_dir() { 12 | let (at, mut ucmd) = at_and_ucmd!(); 13 | // Create a 256-character path to current directory 14 | let dir = path_concat!(".", ..128); 15 | ucmd.arg(dir).run().stdout_is(at.root_dir_resolved()); 16 | } 17 | 18 | #[test] 19 | fn test_long_redirection_to_root() { 20 | // Create a 255-character path to root 21 | let dir = path_concat!("..", ..85); 22 | new_ucmd!().arg(dir).run().stdout_is(get_root_path()); 23 | } 24 | -------------------------------------------------------------------------------- /src/uucore/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "uucore" 3 | version = "0.0.1" 4 | authors = [] 5 | 6 | [dependencies] 7 | getopts = "*" 8 | time = { version = "*", optional = true } 9 | data-encoding = { version = "^1.1", optional = true } 10 | 11 | [dependencies.libc] 12 | git = "https://github.com/rust-lang/libc.git" 13 | optional = true 14 | 15 | [features] 16 | fs = ["libc"] 17 | utf8 = [] 18 | encoding = ["data-encoding"] 19 | parse_time = [] 20 | utmpx = ["time", "libc"] 21 | process = ["libc"] 22 | signals = [] 23 | entries = ["libc"] 24 | wide = [] 25 | utsname = ["libc"] 26 | default = ["fs", "libc", "utf8", "utsname", "encoding", "parse_time", "utmpx", "process", "entries", "signals", "wide"] 27 | 28 | [lib] 29 | path = "lib.rs" 30 | name = "uucore" 31 | -------------------------------------------------------------------------------- /tests/test_dirname.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_path_with_trailing_slashes() { 6 | new_ucmd!().arg("/root/alpha/beta/gamma/delta/epsilon/omega//") 7 | .run().stdout_is("/root/alpha/beta/gamma/delta/epsilon"); 8 | } 9 | 10 | #[test] 11 | fn test_path_without_trailing_slashes() { 12 | new_ucmd!().arg("/root/alpha/beta/gamma/delta/epsilon/omega") 13 | .run().stdout_is("/root/alpha/beta/gamma/delta/epsilon"); 14 | } 15 | 16 | #[test] 17 | fn test_root() { 18 | new_ucmd!().arg("/").run().stdout_is("/"); 19 | } 20 | 21 | #[test] 22 | fn test_pwd() { 23 | new_ucmd!().arg(".").run().stdout_is("."); 24 | } 25 | 26 | #[test] 27 | fn test_empty() { 28 | new_ucmd!().arg("").run().stdout_is("."); 29 | } 30 | -------------------------------------------------------------------------------- /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 | 13 | #[test] 14 | fn test_op_prec_and_or_1() { 15 | new_ucmd!() 16 | .args(&[" ", "-o", "", "-a", ""]) 17 | .succeeds(); 18 | } 19 | 20 | #[test] 21 | fn test_op_prec_and_or_2() { 22 | new_ucmd!() 23 | .args(&["", "-a", "", "-o", " ", "-a", " "]) 24 | .succeeds(); 25 | } 26 | 27 | #[test] 28 | fn test_or_as_filename() { 29 | new_ucmd!() 30 | .args(&["x", "-a", "-z", "-o"]) 31 | .fails(); 32 | } 33 | -------------------------------------------------------------------------------- /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/uucore/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(feature = "libc")] 2 | pub extern crate libc; 3 | 4 | #[macro_use] 5 | mod macros; 6 | 7 | #[macro_use] 8 | pub mod coreopts; 9 | 10 | #[cfg(feature = "fs")] 11 | pub mod fs; 12 | #[cfg(feature = "utf8")] 13 | pub mod utf8; 14 | #[cfg(feature = "encoding")] 15 | pub mod encoding; 16 | #[cfg(feature = "parse_time")] 17 | pub mod parse_time; 18 | 19 | #[cfg(all(unix, not(target_os = "fuchsia"), feature = "utmpx"))] 20 | pub mod utmpx; 21 | #[cfg(all(unix, feature = "utsname"))] 22 | pub mod utsname; 23 | #[cfg(all(unix, feature = "entries"))] 24 | pub mod entries; 25 | #[cfg(all(unix, feature = "process"))] 26 | pub mod process; 27 | #[cfg(all(unix, not(target_os = "fuchsia"), feature = "signals"))] 28 | pub mod signals; 29 | 30 | #[cfg(all(windows, feature = "wide"))] 31 | pub mod wide; 32 | -------------------------------------------------------------------------------- /src/arch/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 | #[macro_use] 13 | extern crate uucore; 14 | use uucore::utsname::Uname; 15 | 16 | static SYNTAX: &'static str = ""; 17 | static SUMMARY: &'static str = "Determine architecture name for current machine."; 18 | static LONG_HELP: &'static str = ""; 19 | 20 | pub fn uumain(args: Vec) -> i32 { 21 | new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); 22 | let uts = Uname::new(); 23 | println!("{}", uts.machine().trim()); 24 | 0 25 | } 26 | -------------------------------------------------------------------------------- /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/test_tr.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_toupper() { 6 | new_ucmd!() 7 | .args(&["a-z", "A-Z"]).pipe_in("!abcd!").run().stdout_is("!ABCD!"); 8 | } 9 | 10 | #[test] 11 | fn test_small_set2() { 12 | new_ucmd!() 13 | .args(&["0-9", "X"]).pipe_in("@0123456789").run().stdout_is("@XXXXXXXXXX"); 14 | } 15 | 16 | #[test] 17 | fn test_unicode() { 18 | new_ucmd!() 19 | .args(&[", ┬─┬", "╯︵┻━┻"]) 20 | .pipe_in("(,°□°), ┬─┬").run() 21 | .stdout_is("(╯°□°)╯︵┻━┻"); 22 | } 23 | 24 | #[test] 25 | fn test_delete() { 26 | new_ucmd!() 27 | .args(&["-d", "a-z"]).pipe_in("aBcD").run().stdout_is("BD"); 28 | } 29 | 30 | #[test] 31 | fn test_delete_complement() { 32 | new_ucmd!() 33 | .args(&["-d", "-c", "a-z"]).pipe_in("aBcD").run().stdout_is("ac"); 34 | } 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | * `--quiet` : never output headers giving file names 8 | * `--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` 9 | 10 | ### Others 11 | The current implementation does not handle `-` as an alias for stdin. 12 | 13 | ##Possible optimizations: 14 | * 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. 15 | -------------------------------------------------------------------------------- /tests/test_truncate.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | use std::io::{Seek, SeekFrom, Write}; 3 | 4 | 5 | static TFILE1: &'static str = "truncate_test_1"; 6 | static TFILE2: &'static str = "truncate_test_2"; 7 | 8 | #[test] 9 | fn test_increase_file_size() { 10 | let (at, mut ucmd) = at_and_ucmd!(); 11 | let mut file = at.make_file(TFILE1); 12 | ucmd.args(&["-s", "+5K", TFILE1]).succeeds(); 13 | 14 | file.seek(SeekFrom::End(0)).unwrap(); 15 | assert!(file.seek(SeekFrom::Current(0)).unwrap() == 5 * 1024); 16 | } 17 | 18 | #[test] 19 | fn test_decrease_file_size() { 20 | let (at, mut ucmd) = at_and_ucmd!(); 21 | let mut file = at.make_file(TFILE2); 22 | file.write_all(b"1234567890").unwrap(); 23 | ucmd.args(&["--size=-4", TFILE2]).succeeds(); 24 | file.seek(SeekFrom::End(0)).unwrap(); 25 | assert!(file.seek(SeekFrom::Current(0)).unwrap() == 6); 26 | } 27 | -------------------------------------------------------------------------------- /src/printf/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 | -------------------------------------------------------------------------------- /src/whoami/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 winapi; 11 | extern crate advapi32; 12 | extern crate uucore; 13 | 14 | use std::io::{Error, Result}; 15 | use std::mem; 16 | use uucore::wide::FromWide; 17 | 18 | pub unsafe fn getusername() -> Result { 19 | let mut buffer: [winapi::WCHAR; winapi::UNLEN as usize + 1] = mem::uninitialized(); 20 | let mut len = buffer.len() as winapi::DWORD; 21 | if advapi32::GetUserNameW(buffer.as_mut_ptr(), &mut len) == 0 { 22 | return Err(Error::last_os_error()) 23 | } 24 | let username = String::from_wide(&buffer[..len as usize - 1]); 25 | Ok(username) 26 | } 27 | -------------------------------------------------------------------------------- /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/test_expr.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_simple_arithmetic() { 6 | new_ucmd!().args(&["1", "+", "1"]).run().stdout_is("2\n"); 7 | 8 | new_ucmd!().args(&["1", "-", "1"]).run().stdout_is("0\n"); 9 | 10 | new_ucmd!().args(&["3", "*", "2"]).run().stdout_is("6\n"); 11 | 12 | new_ucmd!().args(&["4", "/", "2"]).run().stdout_is("2\n"); 13 | } 14 | 15 | #[test] 16 | fn test_parenthesis() { 17 | new_ucmd!().args(&["(", "1", "+", "1", ")", "*", "2"]).run().stdout_is("4\n"); 18 | } 19 | 20 | #[test] 21 | fn test_or() { 22 | new_ucmd!().args(&["0", "|", "foo"]).run().stdout_is("foo\n"); 23 | 24 | new_ucmd!().args(&["foo", "|", "bar"]).run().stdout_is("foo\n"); 25 | } 26 | 27 | #[test] 28 | fn test_and() { 29 | new_ucmd!().args(&["foo", "&", "1"]).run().stdout_is("foo\n"); 30 | 31 | new_ucmd!().args(&["", "&", "1"]).run().stdout_is("0\n"); 32 | } 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/printf/cli.rs: -------------------------------------------------------------------------------- 1 | //! stdio convenience fns 2 | #[allow(unused_must_use)] 3 | 4 | use std::io::{stderr, stdout, Write}; 5 | use std::env; 6 | 7 | pub static EXIT_OK: i32 = 0; 8 | pub static EXIT_ERR: i32 = 1; 9 | 10 | pub fn err_msg(msg: &str) { 11 | let exe_path = match env::current_exe() { 12 | Ok(p) => p.to_string_lossy().into_owned(), 13 | _ => String::from(""), 14 | }; 15 | writeln!(&mut stderr(), "{}: {}", exe_path, msg).unwrap(); 16 | } 17 | 18 | // by default stdout only flushes 19 | // to console when a newline is passed. 20 | #[allow(unused_must_use)] 21 | pub fn flush_char(c: &char) { 22 | print!("{}", c); 23 | stdout().flush(); 24 | } 25 | #[allow(unused_must_use)] 26 | pub fn flush_str(s: &str) { 27 | print!("{}", s); 28 | stdout().flush(); 29 | } 30 | #[allow(unused_must_use)] 31 | pub fn flush_bytes(bslice: &[u8]) { 32 | stdout().write(bslice); 33 | stdout().flush(); 34 | } 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/uucore/utf8.rs: -------------------------------------------------------------------------------- 1 | /* This is taken from the rust_unicode crate. Remove once 'unicode' becomes stable */ 2 | 3 | // https://tools.ietf.org/html/rfc3629 4 | static UTF8_CHAR_WIDTH: [u8; 256] = [ 5 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 6 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F 7 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 8 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x3F 9 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 10 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x5F 11 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 12 | 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x7F 13 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 14 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x9F 15 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 16 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xBF 17 | 0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 18 | 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xDF 19 | 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, // 0xEF 20 | 4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0, // 0xFF 21 | ]; 22 | 23 | /// Given a first byte, determine how many bytes are in this UTF-8 character 24 | #[inline] 25 | pub fn utf8_char_width(b: u8) -> usize { 26 | return UTF8_CHAR_WIDTH[b as usize] as usize; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/test_mkdir.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | static TEST_DIR1: &'static str = "mkdir_test1"; 5 | static TEST_DIR2: &'static str = "mkdir_test2"; 6 | static TEST_DIR3: &'static str = "mkdir_test3"; 7 | static TEST_DIR4: &'static str = "mkdir_test4/mkdir_test4_1"; 8 | static TEST_DIR5: &'static str = "mkdir_test5/mkdir_test5_1"; 9 | 10 | #[test] 11 | fn test_mkdir_mkdir() { 12 | new_ucmd!().arg(TEST_DIR1).succeeds(); 13 | } 14 | 15 | #[test] 16 | fn test_mkdir_dup_dir() { 17 | let scene = TestScenario::new(util_name!()); 18 | scene.ucmd().arg(TEST_DIR2).succeeds(); 19 | scene.ucmd().arg(TEST_DIR2).succeeds(); 20 | } 21 | 22 | #[test] 23 | fn test_mkdir_mode() { 24 | new_ucmd!() 25 | .arg("-m") 26 | .arg("755") 27 | .arg(TEST_DIR3) 28 | .succeeds(); 29 | } 30 | 31 | #[test] 32 | fn test_mkdir_parent() { 33 | let scene = TestScenario::new(util_name!()); 34 | scene.ucmd().arg("-p").arg(TEST_DIR4).succeeds(); 35 | scene.ucmd().arg("-p").arg(TEST_DIR4).succeeds(); 36 | } 37 | 38 | #[test] 39 | fn test_mkdir_no_parent() { 40 | new_ucmd!().arg(TEST_DIR5).fails(); 41 | } 42 | -------------------------------------------------------------------------------- /src/cksum/gen_table.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Arcterus 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::fs::File; 12 | use std::io::Write; 13 | 14 | static CRC_TABLE_LEN: usize = 256; 15 | 16 | fn main() { 17 | let mut table = Vec::with_capacity(CRC_TABLE_LEN); 18 | for num in (0 .. CRC_TABLE_LEN) { 19 | table.push(crc_entry(num as u8) as u32); 20 | } 21 | let file = File::create("crc_table.rs").unwrap_or_else(|e| panic!("{}", e)); 22 | write!(&file, "/* auto-generated (DO NOT EDIT) */ 23 | 24 | pub static CRC_TABLE: [u32; {}] = {:?};", CRC_TABLE_LEN, table).unwrap(); 25 | } 26 | 27 | #[inline] 28 | fn crc_entry(input: u8) -> u32 { 29 | let mut crc = (input as u32) << 24; 30 | 31 | for _ in (0 .. 8) { 32 | if crc & 0x80000000 != 0 { 33 | crc <<= 1; 34 | crc ^= 0x04c11db7; 35 | } else { 36 | crc <<= 1; 37 | } 38 | } 39 | 40 | crc 41 | } 42 | -------------------------------------------------------------------------------- /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/tail/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 { pid: self::Pid } 17 | 18 | impl ProcessChecker { 19 | pub fn new(process_id: self::Pid) -> ProcessChecker { 20 | ProcessChecker { pid: process_id } 21 | } 22 | 23 | // Borrowing mutably to be aligned with Windows implementation 24 | pub fn is_dead(&mut self) -> bool { 25 | unsafe { 26 | libc::kill(self.pid, 0) != 0 && get_errno() != libc::EPERM 27 | } 28 | } 29 | } 30 | 31 | impl Drop for ProcessChecker { 32 | fn drop(&mut self) { 33 | } 34 | } 35 | 36 | pub fn supports_pid_checks(pid: self::Pid) -> bool { 37 | unsafe { 38 | !(libc::kill(pid, 0) != 0 && get_errno() == libc::ENOSYS) 39 | } 40 | } 41 | 42 | #[inline] 43 | fn get_errno() -> i32 { 44 | Error::last_os_error().raw_os_error().unwrap() 45 | } 46 | -------------------------------------------------------------------------------- /src/uucore/wide.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Peter Atashian 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | use std::ffi::{OsStr, OsString}; 10 | use std::os::windows::ffi::{OsStrExt, OsStringExt}; 11 | pub trait ToWide { 12 | fn to_wide(&self) -> Vec; 13 | fn to_wide_null(&self) -> Vec; 14 | } 15 | impl ToWide for T where T: AsRef { 16 | fn to_wide(&self) -> Vec { 17 | self.as_ref().encode_wide().collect() 18 | } 19 | fn to_wide_null(&self) -> Vec { 20 | self.as_ref().encode_wide().chain(Some(0)).collect() 21 | } 22 | } 23 | pub trait FromWide { 24 | fn from_wide(wide: &[u16]) -> Self; 25 | fn from_wide_null(wide: &[u16]) -> Self; 26 | } 27 | impl FromWide for String { 28 | fn from_wide(wide: &[u16]) -> String { 29 | OsString::from_wide(wide).to_string_lossy().into_owned() 30 | } 31 | fn from_wide_null(wide: &[u16]) -> String { 32 | let len = wide.iter().take_while(|&&c| c != 0).count(); 33 | OsString::from_wide(&wide[..len]).to_string_lossy().into_owned() 34 | } 35 | } -------------------------------------------------------------------------------- /src/groups/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::{Passwd, Locate, get_groups, gid2grp}; 16 | use std::io::Write; 17 | 18 | static SYNTAX: &'static str = "[user]"; 19 | static SUMMARY: &'static str = "display current group names"; 20 | 21 | pub fn uumain(args: Vec) -> i32 { 22 | let matches = new_coreopts!(SYNTAX, SUMMARY, "") 23 | .parse(args); 24 | 25 | if matches.free.is_empty() { 26 | println!("{}", get_groups().unwrap().iter().map(|&g| gid2grp(g).unwrap()).collect::>().join(" ")); 27 | } else { 28 | if let Ok(p) = Passwd::locate(matches.free[0].as_str()) { 29 | println!("{}", p.belongs_to().iter().map(|&g| gid2grp(g).unwrap()).collect::>().join(" ")); 30 | } else { 31 | crash!(1, "unknown user {}", matches.free[0]); 32 | } 33 | } 34 | 35 | 0 36 | } 37 | -------------------------------------------------------------------------------- /tests/test_link.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_link_existing_file() { 6 | let (at, mut ucmd) = at_and_ucmd!(); 7 | let file = "test_link_existing_file"; 8 | let link = "test_link_existing_file_link"; 9 | 10 | at.touch(file); 11 | at.write(file, "foobar"); 12 | assert!(at.file_exists(file)); 13 | 14 | ucmd.args(&[file, link]).succeeds().no_stderr(); 15 | assert!(at.file_exists(file)); 16 | assert!(at.file_exists(link)); 17 | assert_eq!(at.read(file), at.read(link)); 18 | } 19 | 20 | #[test] 21 | fn test_link_no_circular() { 22 | let (at, mut ucmd) = at_and_ucmd!(); 23 | let link = "test_link_no_circular"; 24 | 25 | ucmd.args(&[link, link]).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]).fails() 37 | .stderr_is("link: error: No such file or directory (os error 2)\n"); 38 | assert!(!at.file_exists(file)); 39 | assert!(!at.file_exists(link)); 40 | } 41 | -------------------------------------------------------------------------------- /src/printf/tokenize/token.rs: -------------------------------------------------------------------------------- 1 | //! Traits and enums dealing with Tokenization of printf Format String 2 | #[allow(unused_must_use)] 3 | 4 | use std::iter::Peekable; 5 | use std::str::Chars; 6 | use std::slice::Iter; 7 | use itertools::PutBackN; 8 | 9 | // A token object is an object that can print the expected output 10 | // of a contiguous segment of the format string, and 11 | // requires at most 1 argusegment 12 | pub trait Token { 13 | fn print(&self, args: &mut Peekable>); 14 | } 15 | 16 | // A tokenizer object is an object that takes an iterator 17 | // at a position in a format string, and sees whether 18 | // it can return a token of a type it knows how to produce 19 | // if so, return the token, move the iterator past the 20 | // format string text the token represents, and if an 21 | // argument is used move the argument iter forward one 22 | 23 | // creating token of a format string segment should also cause 24 | // printing of that token's value. Essentially tokenizing 25 | // a whole format string will print the format string and consume 26 | // a number of arguments equal to the number of argument-using tokens 27 | 28 | pub trait Tokenizer { 29 | fn from_it(it: &mut PutBackN, args: &mut Peekable>) -> Option>; 30 | } 31 | -------------------------------------------------------------------------------- /tests/test_tac.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_stdin_default() { 6 | new_ucmd!() 7 | .pipe_in("100\n200\n300\n400\n500") 8 | .run() 9 | .stdout_is("500400\n300\n200\n100\n"); 10 | } 11 | 12 | #[test] 13 | fn test_stdin_non_newline_separator() { 14 | new_ucmd!() 15 | .args(&["-s", ":"]) 16 | .pipe_in("100:200:300:400:500") 17 | .run() 18 | .stdout_is("500400:300:200:100:"); 19 | } 20 | 21 | #[test] 22 | fn test_stdin_non_newline_separator_before() { 23 | new_ucmd!() 24 | .args(&["-b", "-s", ":"]) 25 | .pipe_in("100:200:300:400:500") 26 | .run() 27 | .stdout_is("500:400:300:200:100"); 28 | } 29 | 30 | #[test] 31 | fn test_single_default() { 32 | new_ucmd!().arg("prime_per_line.txt") 33 | .run().stdout_is_fixture("prime_per_line.expected"); 34 | } 35 | 36 | #[test] 37 | fn test_single_non_newline_separator() { 38 | new_ucmd!().args(&["-s", ":", "delimited_primes.txt"]) 39 | .run().stdout_is_fixture("delimited_primes.expected"); 40 | } 41 | 42 | #[test] 43 | fn test_single_non_newline_separator_before() { 44 | new_ucmd!().args(&["-b", "-s", ":", "delimited_primes.txt"]) 45 | .run().stdout_is_fixture("delimited_primes_before.expected"); 46 | } 47 | -------------------------------------------------------------------------------- /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/test_sum.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_bsd_single_file() { 6 | new_ucmd!() 7 | .arg("lorem_ipsum.txt") 8 | .succeeds().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().stdout_only_fixture("bsd_multiple_files.expected"); 17 | } 18 | 19 | #[test] 20 | fn test_bsd_stdin() { 21 | new_ucmd!() 22 | .pipe_in_fixture("lorem_ipsum.txt") 23 | .succeeds().stdout_only_fixture("bsd_stdin.expected"); 24 | } 25 | 26 | #[test] 27 | fn test_sysv_single_file() { 28 | new_ucmd!() 29 | .arg("-s").arg("lorem_ipsum.txt") 30 | .succeeds().stdout_only_fixture("sysv_single_file.expected"); 31 | } 32 | 33 | #[test] 34 | fn test_sysv_multiple_files() { 35 | new_ucmd!() 36 | .arg("-s") 37 | .arg("lorem_ipsum.txt") 38 | .arg("alice_in_wonderland.txt") 39 | .succeeds().stdout_only_fixture("sysv_multiple_files.expected"); 40 | } 41 | 42 | #[test] 43 | fn test_sysv_stdin() { 44 | new_ucmd!() 45 | .arg("-s") 46 | .pipe_in_fixture("lorem_ipsum.txt") 47 | .succeeds().stdout_only_fixture("sysv_stdin.expected"); 48 | } 49 | -------------------------------------------------------------------------------- /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/uucore/utsname.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 | use super::libc::{uname, utsname}; 10 | use ::std::mem; 11 | use ::std::ffi::CStr; 12 | use ::std::borrow::Cow; 13 | 14 | macro_rules! cstr2cow { 15 | ($v:expr) => ( 16 | unsafe { CStr::from_ptr($v.as_ref().as_ptr()).to_string_lossy() } 17 | ) 18 | } 19 | 20 | pub struct Uname { 21 | inner: utsname, 22 | } 23 | 24 | impl Uname { 25 | pub fn new() -> Self { 26 | unsafe { 27 | let mut uts: utsname = mem::uninitialized(); 28 | uname(&mut uts); 29 | Uname { inner: uts } 30 | } 31 | } 32 | 33 | pub fn sysname(&self) -> Cow { 34 | cstr2cow!(self.inner.sysname) 35 | } 36 | 37 | pub fn nodename(&self) -> Cow { 38 | cstr2cow!(self.inner.nodename) 39 | } 40 | 41 | pub fn release(&self) -> Cow { 42 | cstr2cow!(self.inner.release) 43 | } 44 | 45 | pub fn version(&self) -> Cow { 46 | cstr2cow!(self.inner.version) 47 | } 48 | 49 | pub fn machine(&self) -> Cow { 50 | cstr2cow!(self.inner.machine) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/hostid/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: &'static str = "[options]"; 20 | static SUMMARY: &'static str = ""; 21 | static LONG_HELP: &'static str = ""; 22 | 23 | pub enum Mode { 24 | HostId, 25 | Help, 26 | Version, 27 | } 28 | 29 | // currently rust libc interface doesn't include gethostid 30 | extern { 31 | pub fn gethostid() -> c_long; 32 | } 33 | 34 | pub fn uumain(args: Vec) -> i32 { 35 | new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) 36 | .parse(args); 37 | hostid(); 38 | 0 39 | } 40 | 41 | fn hostid() { 42 | /* 43 | * POSIX says gethostid returns a "32-bit identifier" but is silent 44 | * whether it's sign-extended. Turn off any sign-extension. This 45 | * is a no-op unless unsigned int is wider than 32 bits. 46 | */ 47 | 48 | let mut result:c_long; 49 | unsafe { 50 | result = gethostid(); 51 | } 52 | 53 | result &= 0xffffffff; 54 | println!("{:0>8x}", result); 55 | } 56 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/test_unlink.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_unlink_file() { 6 | let (at, mut ucmd) = at_and_ucmd!(); 7 | let file = "test_unlink_file"; 8 | 9 | at.touch(file); 10 | 11 | ucmd.arg(file).succeeds().no_stderr(); 12 | 13 | assert!(!at.file_exists(file)); 14 | } 15 | 16 | #[test] 17 | fn test_unlink_multiple_files() { 18 | let (at, mut ucmd) = at_and_ucmd!(); 19 | let file_a = "test_unlink_multiple_file_a"; 20 | let file_b = "test_unlink_multiple_file_b"; 21 | 22 | at.touch(file_a); 23 | at.touch(file_b); 24 | 25 | ucmd.arg(file_a).arg(file_b).fails() 26 | .stderr_is("unlink: error: extra operand: 'test_unlink_multiple_file_b'\nTry 'unlink --help' \ 27 | for more information.\n"); 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() 38 | .stderr_is("unlink: error: cannot unlink 'test_unlink_empty_directory': Not a regular file \ 39 | or symlink\n"); 40 | } 41 | 42 | #[test] 43 | fn test_unlink_nonexistent() { 44 | let file = "test_unlink_nonexistent"; 45 | 46 | new_ucmd!().arg(file).fails() 47 | .stderr_is("unlink: error: Cannot stat 'test_unlink_nonexistent': No such file or directory \ 48 | (os error 2)\n"); 49 | } 50 | -------------------------------------------------------------------------------- /src/link/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::Write; 17 | use std::path::Path; 18 | use std::io::Error; 19 | 20 | static SYNTAX: &'static str = "[OPTIONS] FILE1 FILE2"; 21 | static SUMMARY: &'static str = "Create a link named FILE2 to FILE1"; 22 | static LONG_HELP: &'static str = ""; 23 | 24 | pub fn normalize_error_message(e: Error) -> String { 25 | match e.raw_os_error() { 26 | Some(2) => { String::from("No such file or directory (os error 2)") } 27 | _ => { format!("{}", e) } 28 | } 29 | } 30 | 31 | pub fn uumain(args: Vec) -> i32 { 32 | let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP) 33 | .parse(args); 34 | if matches.free.len() != 2 { 35 | crash!(1, "{}", msg_wrong_number_of_arguments!(2)); 36 | } 37 | 38 | let old = Path::new(&matches.free[0]); 39 | let new = Path::new(&matches.free[1]); 40 | 41 | match hard_link(old, new) { 42 | Ok(_) => 0, 43 | Err(err) => { 44 | show_error!("{}",normalize_error_message(err)); 45 | 1 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tests/test_chown.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | extern crate uu_chown; 4 | pub use self::uu_chown::*; 5 | 6 | 7 | #[cfg(test)] 8 | mod test_passgrp { 9 | use super::uu_chown::entries::{usr2uid,grp2gid,uid2usr,gid2grp}; 10 | 11 | #[test] 12 | fn test_usr2uid() { 13 | assert_eq!(0, usr2uid("root").unwrap()); 14 | assert!(usr2uid("88888888").is_err()); 15 | assert!(usr2uid("auserthatdoesntexist").is_err()); 16 | } 17 | 18 | #[test] 19 | fn test_grp2gid() { 20 | if cfg!(target_os = "macos") { 21 | assert_eq!(0, grp2gid("wheel").unwrap()); 22 | } else { 23 | assert_eq!(0, grp2gid("root").unwrap()); 24 | } 25 | assert!(grp2gid("88888888").is_err()); 26 | assert!(grp2gid("agroupthatdoesntexist").is_err()); 27 | } 28 | 29 | #[test] 30 | fn test_uid2usr() { 31 | assert_eq!("root", uid2usr(0).unwrap()); 32 | assert!(uid2usr(88888888).is_err()); 33 | } 34 | 35 | #[test] 36 | fn test_gid2grp() { 37 | if cfg!(target_os = "macos") { 38 | assert_eq!("wheel", gid2grp(0).unwrap()); 39 | } else { 40 | assert_eq!("root", gid2grp(0).unwrap()); 41 | } 42 | assert!(gid2grp(88888888).is_err()); 43 | } 44 | } 45 | 46 | #[test] 47 | fn test_invalid_option() { 48 | new_ucmd!() 49 | .arg("-w").arg("-q").arg("/") 50 | .fails(); 51 | } 52 | -------------------------------------------------------------------------------- /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/pwd/pwd.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_pwd"] 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 | extern crate getopts; 13 | 14 | #[macro_use] 15 | extern crate uucore; 16 | 17 | use std::io::Write; 18 | use std::env; 19 | 20 | static NAME: &'static str = "pwd"; 21 | static VERSION: &'static str = env!("CARGO_PKG_VERSION"); 22 | 23 | pub fn uumain(args: Vec) -> i32 { 24 | let mut opts = getopts::Options::new(); 25 | 26 | opts.optflag("", "help", "display this help and exit"); 27 | opts.optflag("", "version", "output version information and exit"); 28 | 29 | let matches = match opts.parse(&args[1..]) { 30 | Ok(m) => m, 31 | Err(f) => { 32 | crash!(1, "Invalid options\n{}", f) 33 | } 34 | }; 35 | 36 | if matches.opt_present("help") { 37 | let msg = format!("{0} {1} 38 | 39 | Usage: 40 | {0} [OPTION]... 41 | 42 | Print the full filename of the current working directory.", NAME, VERSION); 43 | print!("{}", opts.usage(&msg)); 44 | } else if matches.opt_present("version") { 45 | println!("{} {}", NAME, VERSION); 46 | } else { 47 | println!("{}", env::current_dir().unwrap().display()); 48 | } 49 | 50 | 0 51 | } 52 | -------------------------------------------------------------------------------- /src/logname/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 | use std::io::Write; 21 | 22 | extern { 23 | // POSIX requires using getlogin (or equivalent code) 24 | pub fn getlogin() -> *const libc::c_char; 25 | } 26 | 27 | fn get_userlogin() -> Option { 28 | unsafe { 29 | let login: *const libc::c_char = getlogin(); 30 | if login.is_null() { 31 | None 32 | } else { 33 | Some(String::from_utf8_lossy(CStr::from_ptr(login).to_bytes()).to_string()) 34 | } 35 | } 36 | } 37 | 38 | static SYNTAX: &'static str = ""; 39 | static SUMMARY: &'static str = "Print user's login name"; 40 | static LONG_HELP: &'static str = ""; 41 | 42 | pub fn uumain(args: Vec) -> i32 { 43 | new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args); 44 | 45 | exec(); 46 | 47 | 0 48 | } 49 | 50 | fn exec() { 51 | match get_userlogin() { 52 | Some(userlogin) => println!("{}", userlogin), 53 | None => show_error!("no login name") 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tests/test_readlink.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | static GIBBERISH: &'static str = "supercalifragilisticexpialidocious"; 5 | 6 | #[test] 7 | fn test_canonicalize() { 8 | let (at, mut ucmd) = at_and_ucmd!(); 9 | ucmd.arg("-f") 10 | .arg(".") 11 | .run() 12 | .stdout_is(at.root_dir_resolved()); 13 | } 14 | 15 | #[test] 16 | fn test_canonicalize_existing() { 17 | let (at, mut ucmd) = at_and_ucmd!(); 18 | ucmd.arg("-e") 19 | .arg(".") 20 | .run() 21 | .stdout_is(at.root_dir_resolved()); 22 | } 23 | 24 | #[test] 25 | fn test_canonicalize_missing() { 26 | let (at, mut ucmd) = at_and_ucmd!(); 27 | let expected = path_concat!(at.root_dir_resolved(), GIBBERISH); 28 | ucmd.arg("-m") 29 | .arg(GIBBERISH) 30 | .run() 31 | .stdout_is(expected); 32 | } 33 | 34 | #[test] 35 | fn test_long_redirection_to_current_dir() { 36 | let (at, mut ucmd) = at_and_ucmd!(); 37 | // Create a 256-character path to current directory 38 | let dir = path_concat!(".", ..128); 39 | ucmd.arg("-n") 40 | .arg("-m") 41 | .arg(dir) 42 | .run() 43 | .stdout_is(at.root_dir_resolved()); 44 | } 45 | 46 | #[test] 47 | fn test_long_redirection_to_root() { 48 | // Create a 255-character path to root 49 | let dir = path_concat!("..", ..85); 50 | new_ucmd!() 51 | .arg("-n") 52 | .arg("-m") 53 | .arg(dir) 54 | .run() 55 | .stdout_is(get_root_path()); 56 | } 57 | -------------------------------------------------------------------------------- /tests/test_ptx.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn gnu_ext_disabled_roff_no_ref() { 6 | new_ucmd!().args(&["-G", "-R", "input"]) 7 | .succeeds().stdout_only_fixture("gnu_ext_disabled_roff_no_ref.expected"); 8 | } 9 | 10 | #[test] 11 | fn gnu_ext_disabled_roff_input_ref() { 12 | new_ucmd!().args(&["-G", "-r", "-R", "input"]) 13 | .succeeds().stdout_only_fixture("gnu_ext_disabled_roff_input_ref.expected"); 14 | } 15 | 16 | #[test] 17 | fn gnu_ext_disabled_roff_auto_ref() { 18 | new_ucmd!().args(&["-G", "-A", "-R", "input"]) 19 | .succeeds().stdout_only_fixture("gnu_ext_disabled_roff_auto_ref.expected"); 20 | } 21 | 22 | #[test] 23 | fn gnu_ext_disabled_tex_no_ref() { 24 | new_ucmd!().args(&["-G", "-T", "-R", "input"]) 25 | .succeeds().stdout_only_fixture("gnu_ext_disabled_tex_no_ref.expected"); 26 | } 27 | 28 | #[test] 29 | fn gnu_ext_disabled_tex_input_ref() { 30 | new_ucmd!().args(&["-G", "-T", "-r", "-R", "input"]) 31 | .succeeds().stdout_only_fixture("gnu_ext_disabled_tex_input_ref.expected"); 32 | } 33 | 34 | #[test] 35 | fn gnu_ext_disabled_tex_auto_ref() { 36 | new_ucmd!().args(&["-G", "-T", "-A", "-R", "input"]) 37 | .succeeds().stdout_only_fixture("gnu_ext_disabled_tex_auto_ref.expected"); 38 | } 39 | 40 | #[test] 41 | fn gnu_ext_disabled_ignore_and_only_file() { 42 | new_ucmd!().args(&["-G", "-o", "only", "-i", "ignore", "input"]) 43 | .succeeds().stdout_only_fixture("gnu_ext_disabled_ignore_and_only_file.expected"); 44 | } 45 | -------------------------------------------------------------------------------- /tests/test_wc.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_stdin_default() { 6 | new_ucmd!().pipe_in_fixture("lorem_ipsum.txt") 7 | .run().stdout_is(" 13 109 772\n"); 8 | } 9 | 10 | #[test] 11 | fn test_stdin_only_bytes() { 12 | new_ucmd!().args(&["-c"]).pipe_in_fixture("lorem_ipsum.txt") 13 | .run().stdout_is(" 772\n"); 14 | } 15 | 16 | #[test] 17 | fn test_stdin_all_counts() { 18 | new_ucmd!().args(&["-c", "-m", "-l", "-L", "-w"]) 19 | .pipe_in_fixture("alice_in_wonderland.txt") 20 | .run() 21 | .stdout_is(" 5 57 302 302 66\n"); 22 | } 23 | 24 | #[test] 25 | fn test_single_default() { 26 | new_ucmd!() 27 | .arg("moby_dick.txt").run().stdout_is(" 18 204 1115 moby_dick.txt\n"); 28 | } 29 | 30 | #[test] 31 | fn test_single_only_lines() { 32 | new_ucmd!() 33 | .args(&["-l", "moby_dick.txt"]).run().stdout_is(" 18 moby_dick.txt\n"); 34 | } 35 | 36 | #[test] 37 | fn test_single_all_counts() { 38 | new_ucmd!() 39 | .args(&["-c", "-l", "-L", "-m", "-w", "alice_in_wonderland.txt"]).run() 40 | .stdout_is(" 5 57 302 302 66 alice_in_wonderland.txt\n"); 41 | } 42 | 43 | #[test] 44 | fn test_multiple_default() { 45 | new_ucmd!() 46 | .args(&["lorem_ipsum.txt", "moby_dick.txt", "alice_in_wonderland.txt"]).run() 47 | .stdout_is( 48 | " 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 5 57 302 \ 49 | alice_in_wonderland.txt\n 36 370 2189 total\n"); 50 | } 51 | -------------------------------------------------------------------------------- /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/mktemp/tempdir.rs: -------------------------------------------------------------------------------- 1 | // Mainly taken from crate `tempdir` 2 | 3 | extern crate rand; 4 | use rand::{Rng, thread_rng}; 5 | 6 | use std::io::Result as IOResult; 7 | use std::io::{Error, ErrorKind}; 8 | use std::path::Path; 9 | 10 | // How many times should we (re)try finding an unused random name? It should be 11 | // enough that an attacker will run out of luck before we run out of patience. 12 | const NUM_RETRIES: u32 = 1 << 31; 13 | 14 | #[cfg(unix)] 15 | fn create_dir>(path: P) -> IOResult<()> { 16 | use std::fs::DirBuilder; 17 | use std::os::unix::fs::DirBuilderExt; 18 | 19 | DirBuilder::new().mode(0o700).create(path) 20 | } 21 | 22 | #[cfg(windows)] 23 | fn create_dir>(path: P) -> IOResult<()> { 24 | ::std::fs::create_dir(path) 25 | } 26 | 27 | pub fn new_in>(tmpdir: P, prefix: &str, rand: usize, suffix: &str) -> IOResult { 28 | 29 | let mut rng = thread_rng(); 30 | for _ in 0..NUM_RETRIES { 31 | let rand_chars: String = rng.gen_ascii_chars().take(rand).collect(); 32 | let leaf = format!("{}{}{}", prefix, rand_chars, suffix); 33 | let path = tmpdir.as_ref().join(&leaf); 34 | match create_dir(&path) { 35 | Ok(_) => return Ok(path.to_string_lossy().into_owned()), 36 | Err(ref e) if e.kind() == ErrorKind::AlreadyExists => {} 37 | Err(e) => return Err(e), 38 | } 39 | } 40 | 41 | Err(Error::new(ErrorKind::AlreadyExists, 42 | "too many temporary directories already exist")) 43 | } 44 | -------------------------------------------------------------------------------- /src/printf/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::{InPrefix, FormatPrimitive, Formatter}; 4 | use super::float_common::{FloatAnalysis, get_primitive_dec, primitive_to_str_common}; 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(&self, 16 | field: &FormatField, 17 | inprefix: &InPrefix, 18 | str_in: &str) 19 | -> Option { 20 | let second_field = field.second_field.unwrap_or(6) + 1; 21 | let analysis = FloatAnalysis::analyze(&str_in, 22 | inprefix, 23 | None, 24 | Some(second_field as usize), 25 | false); 26 | let f = get_primitive_dec(inprefix, 27 | &str_in[inprefix.offset..], 28 | &analysis, 29 | second_field as usize, 30 | None); 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/uucore/parse_time.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the uutils coreutils package. 3 | * 4 | * (c) Arcterus 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 std::time::Duration; 11 | 12 | pub fn from_str(string: &str) -> Result { 13 | let len = string.len(); 14 | if len == 0 { 15 | return Err("empty string".to_owned()) 16 | } 17 | let slice = &string[..len - 1]; 18 | let (numstr, times) = match string.chars().next_back().unwrap() { 19 | 's' | 'S' => (slice, 1), 20 | 'm' | 'M' => (slice, 60), 21 | 'h' | 'H' => (slice, 60 * 60), 22 | 'd' | 'D' => (slice, 60 * 60 * 24), 23 | val => { 24 | if !val.is_alphabetic() { 25 | (string, 1) 26 | } else if string == "inf" || string == "infinity" { 27 | ("inf", 1) 28 | } else { 29 | return Err(format!("invalid time interval '{}'", string)) 30 | } 31 | } 32 | }; 33 | let num = match numstr.parse::() { 34 | Ok(m) => m, 35 | Err(e) => return Err(format!("invalid time interval '{}': {}", string, e)) 36 | }; 37 | 38 | const NANOS_PER_SEC: u32 = 1_000_000_000; 39 | let whole_secs = num.trunc(); 40 | let nanos = (num.fract() * (NANOS_PER_SEC as f64)).trunc(); 41 | let duration = Duration::new(whole_secs as u64, nanos as u32); 42 | Ok(duration * times) 43 | } 44 | -------------------------------------------------------------------------------- /src/printf/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::{InPrefix, FormatPrimitive, Formatter}; 4 | use super::float_common::{FloatAnalysis, get_primitive_dec, primitive_to_str_common}; 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(&self, 16 | field: &FormatField, 17 | inprefix: &InPrefix, 18 | str_in: &str) 19 | -> Option { 20 | let second_field = field.second_field.unwrap_or(6) + 1; 21 | let analysis = FloatAnalysis::analyze(str_in, 22 | inprefix, 23 | Some(second_field as usize + 1), 24 | None, 25 | false); 26 | let f = get_primitive_dec(inprefix, 27 | &str_in[inprefix.offset..], 28 | &analysis, 29 | second_field as usize, 30 | Some(*field.field_char == 'E')); 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/stdbuf/libstdbuf.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "libstdbuf"] 2 | #![crate_type = "staticlib"] 3 | 4 | extern crate libc; 5 | 6 | #[macro_use] 7 | extern crate uucore; 8 | 9 | use libc::{c_int, size_t, c_char, FILE, _IOFBF, _IONBF, _IOLBF, setvbuf}; 10 | use std::env; 11 | use std::io::Write; 12 | use std::ptr; 13 | 14 | extern { 15 | static stdin: *mut FILE; 16 | static stdout: *mut FILE; 17 | static stderr: *mut FILE; 18 | } 19 | 20 | static NAME: &'static str = "libstdbuf"; 21 | 22 | fn set_buffer(stream: *mut FILE, value: &str) { 23 | let (mode, size): (c_int, size_t) = match value { 24 | "0" => (_IONBF, 0 as size_t), 25 | "L" => (_IOLBF, 0 as size_t), 26 | input => { 27 | let buff_size: usize = match input.parse() { 28 | Ok(num) => num, 29 | Err(e) => crash!(1, "incorrect size of buffer!: {}", e) 30 | }; 31 | (_IOFBF, buff_size as size_t) 32 | } 33 | }; 34 | let res: c_int; 35 | unsafe { 36 | let buffer: *mut c_char = ptr::null_mut(); 37 | assert!(buffer.is_null()); 38 | res = libc::setvbuf(stream, buffer, mode, size); 39 | } 40 | if res != 0 { 41 | crash!(res, "error while calling setvbuf!"); 42 | } 43 | } 44 | 45 | #[no_mangle] 46 | pub extern fn stdbuf() { 47 | if let Ok(val) = env::var("_STDBUF_E") { 48 | set_buffer(stderr, &val); 49 | } 50 | if let Ok(val) = env::var("_STDBUF_I") { 51 | set_buffer(stdin, &val); 52 | } 53 | if let Ok(val) = env::var("_STDBUF_O") { 54 | set_buffer(stdout, &val); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/tail/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 winapi; 11 | extern crate kernel32; 12 | 13 | use self::kernel32::{OpenProcess, CloseHandle, WaitForSingleObject}; 14 | use self::winapi::minwindef::DWORD; 15 | use self::winapi::winbase::{WAIT_OBJECT_0, WAIT_FAILED}; 16 | use self::winapi::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 { 30 | OpenProcess(SYNCHRONIZE, FALSE, process_id as DWORD) 31 | }; 32 | ProcessChecker { dead: h.is_null(), handle: h } 33 | } 34 | 35 | pub fn is_dead(&mut self) -> bool { 36 | if !self.dead { 37 | self.dead = unsafe { 38 | let status = WaitForSingleObject(self.handle, 0); 39 | status == WAIT_OBJECT_0 || status == WAIT_FAILED 40 | } 41 | } 42 | 43 | self.dead 44 | } 45 | } 46 | 47 | impl Drop for ProcessChecker { 48 | fn drop(&mut self) { 49 | unsafe { 50 | CloseHandle(self.handle); 51 | } 52 | } 53 | } 54 | 55 | pub fn supports_pid_checks(_pid: self::Pid) -> bool { 56 | true 57 | } 58 | -------------------------------------------------------------------------------- /tests/test_pinky.rs: -------------------------------------------------------------------------------- 1 | extern crate uucore; 2 | 3 | use common::util::*; 4 | 5 | use self::uucore::entries::{Locate, Passwd}; 6 | 7 | extern crate uu_pinky; 8 | pub use self::uu_pinky::*; 9 | 10 | #[test] 11 | fn test_capitalize() { 12 | assert_eq!("Zbnmasd", "zbnmasd".capitalize()); 13 | assert_eq!("Abnmasd", "Abnmasd".capitalize()); 14 | assert_eq!("1masd", "1masd".capitalize()); 15 | assert_eq!("", "".capitalize()); 16 | } 17 | 18 | #[test] 19 | fn test_long_format() { 20 | let ulogin = "root"; 21 | let pw: Passwd = Passwd::locate(ulogin).unwrap(); 22 | let real_name = pw.user_info().replace("&", &pw.name().capitalize()); 23 | new_ucmd!() 24 | .arg("-l").arg(ulogin) 25 | .run() 26 | .stdout_is(format!("Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n", 27 | ulogin, real_name, pw.user_dir(), pw.user_shell())); 28 | 29 | new_ucmd!() 30 | .arg("-lb") 31 | .arg(ulogin) 32 | .run() 33 | .stdout_is(format!("Login name: {:<28}In real life: {1}\n\n", 34 | ulogin, real_name)); 35 | } 36 | 37 | #[cfg(target_os = "linux")] 38 | #[test] 39 | fn test_short_format() { 40 | let scene = TestScenario::new(util_name!()); 41 | 42 | let args = ["-i"]; 43 | scene.ucmd().args(&args).run().stdout_is(expected_result(&args)); 44 | 45 | let args = ["-q"]; 46 | scene.ucmd().args(&args).run().stdout_is(expected_result(&args)); 47 | } 48 | 49 | #[cfg(target_os = "linux")] 50 | fn expected_result(args: &[&str]) -> String { 51 | TestScenario::new(util_name!()).cmd_keepenv(util_name!()).args(args).run().stdout 52 | } 53 | -------------------------------------------------------------------------------- /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 | () => ( module_path!().split("_").nth(1).expect("no test name") ) 53 | } 54 | 55 | #[macro_export] 56 | macro_rules! new_ucmd { 57 | () => ( TestScenario::new(util_name!()).ucmd() ) 58 | } 59 | 60 | #[macro_export] 61 | macro_rules! at_and_ucmd { 62 | () => ({ 63 | let ts = TestScenario::new(util_name!()); 64 | (ts.fixtures.clone(), ts.ucmd()) 65 | }) 66 | } 67 | -------------------------------------------------------------------------------- /src/cut/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: haystack, 21 | needle: 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 | -------------------------------------------------------------------------------- /src/yes/yes.rs: -------------------------------------------------------------------------------- 1 | #![crate_name = "uu_yes"] 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: yes (GNU coreutils) 8.13 */ 13 | 14 | extern crate getopts; 15 | 16 | #[macro_use] 17 | extern crate uucore; 18 | 19 | use getopts::Options; 20 | use std::io::Write; 21 | 22 | static NAME: &'static str = "yes"; 23 | static VERSION: &'static str = env!("CARGO_PKG_VERSION"); 24 | 25 | pub fn uumain(args: Vec) -> i32 { 26 | let mut opts = Options::new(); 27 | 28 | opts.optflag("h", "help", "display this help and exit"); 29 | opts.optflag("V", "version", "output version information and exit"); 30 | 31 | let matches = match opts.parse(&args[1..]) { 32 | Ok(m) => m, 33 | Err(f) => crash!(1, "invalid options\n{}", f) 34 | }; 35 | if matches.opt_present("help") { 36 | println!("{} {}", NAME, VERSION); 37 | println!(""); 38 | println!("Usage:"); 39 | println!(" {0} [STRING]... [OPTION]...", NAME); 40 | println!(""); 41 | print!("{}", opts.usage("Repeatedly output a line with all specified STRING(s), or 'y'.")); 42 | return 0; 43 | } 44 | if matches.opt_present("version") { 45 | println!("{} {}", NAME, VERSION); 46 | return 0; 47 | } 48 | let string = if matches.free.is_empty() { 49 | "y".to_owned() 50 | } else { 51 | matches.free.join(" ") 52 | }; 53 | 54 | exec(&string[..]); 55 | 56 | 0 57 | } 58 | 59 | pub fn exec(string: &str) { 60 | while pipe_println!("{}", string) { } 61 | } 62 | -------------------------------------------------------------------------------- /src/od/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::{NativeEndian, LittleEndian, BigEndian}; 5 | use byteorder::ByteOrder as ByteOrderTrait; 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/od/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 | try!(f.write_str("IntWriter:")); 37 | fmt::Pointer::fmt(p, f) 38 | }, 39 | &FormatWriter::FloatWriter(ref p) => { 40 | try!(f.write_str("FloatWriter:")); 41 | fmt::Pointer::fmt(p, f) 42 | }, 43 | &FormatWriter::MultibyteWriter(ref p) => { 44 | try!(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 | -------------------------------------------------------------------------------- /tests/test_head.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | static INPUT: &'static str = "lorem_ipsum.txt"; 5 | 6 | #[test] 7 | fn test_stdin_default() { 8 | new_ucmd!() 9 | .pipe_in_fixture(INPUT) 10 | .run().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().stdout_is_fixture("lorem_ipsum_1_line.expected"); 19 | } 20 | 21 | #[test] 22 | fn test_stdin_1_line() { 23 | new_ucmd!() 24 | .args(&["-n", "1"]) 25 | .pipe_in_fixture(INPUT) 26 | .run().stdout_is_fixture("lorem_ipsum_1_line.expected"); 27 | } 28 | 29 | #[test] 30 | fn test_stdin_5_chars() { 31 | new_ucmd!() 32 | .args(&["-c", "5"]) 33 | .pipe_in_fixture(INPUT) 34 | .run().stdout_is_fixture("lorem_ipsum_5_chars.expected"); 35 | } 36 | 37 | #[test] 38 | fn test_single_default() { 39 | new_ucmd!() 40 | .arg(INPUT) 41 | .run().stdout_is_fixture("lorem_ipsum_default.expected"); 42 | } 43 | 44 | #[test] 45 | fn test_single_1_line_obsolete() { 46 | new_ucmd!() 47 | .args(&["-1", INPUT]) 48 | .run().stdout_is_fixture("lorem_ipsum_1_line.expected"); 49 | } 50 | 51 | #[test] 52 | fn test_single_1_line() { 53 | new_ucmd!() 54 | .args(&["-n", "1", INPUT]) 55 | .run().stdout_is_fixture("lorem_ipsum_1_line.expected"); 56 | } 57 | 58 | #[test] 59 | fn test_single_5_chars() { 60 | new_ucmd!() 61 | .args(&["-c", "5", INPUT]) 62 | .run().stdout_is_fixture("lorem_ipsum_5_chars.expected"); 63 | } 64 | 65 | #[test] 66 | fn test_verbose() { 67 | new_ucmd!() 68 | .args(&["-v", INPUT]) 69 | .run().stdout_is_fixture("lorem_ipsum_verbose.expected"); 70 | } 71 | -------------------------------------------------------------------------------- /tests/test_who.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | 5 | #[cfg(target_os = "linux")] 6 | #[test] 7 | fn test_count() { 8 | for opt in vec!["-q", "--count"] { 9 | new_ucmd!().arg(opt).run().stdout_is(expected_result(opt)); 10 | } 11 | } 12 | 13 | #[cfg(target_os = "linux")] 14 | #[test] 15 | fn test_boot() { 16 | for opt in vec!["-b", "--boot"] { 17 | new_ucmd!().arg(opt).run().stdout_is(expected_result(opt)); 18 | } 19 | } 20 | 21 | #[cfg(target_os = "linux")] 22 | #[test] 23 | fn test_heading() { 24 | for opt in vec!["-H"] { 25 | new_ucmd!().arg(opt).run().stdout_is(expected_result(opt)); 26 | } 27 | } 28 | 29 | #[cfg(target_os = "linux")] 30 | #[test] 31 | fn test_short() { 32 | for opt in vec!["-s", "--short"] { 33 | new_ucmd!().arg(opt).run().stdout_is(expected_result(opt)); 34 | } 35 | } 36 | 37 | #[cfg(target_os = "linux")] 38 | #[test] 39 | fn test_login() { 40 | for opt in vec!["-l", "--login"] { 41 | new_ucmd!().arg(opt).run().stdout_is(expected_result(opt)); 42 | } 43 | } 44 | 45 | #[cfg(target_os = "linux")] 46 | #[test] 47 | fn test_m() { 48 | for opt in vec!["-m"] { 49 | new_ucmd!().arg(opt).run().stdout_is(expected_result(opt)); 50 | } 51 | } 52 | 53 | #[cfg(target_os = "linux")] 54 | #[test] 55 | fn test_dead() { 56 | for opt in vec!["-d", "--dead"] { 57 | new_ucmd!().arg(opt).run().stdout_is(expected_result(opt)); 58 | } 59 | } 60 | 61 | #[cfg(target_os = "linux")] 62 | #[test] 63 | fn test_all() { 64 | for opt in vec!["-a", "--all"] { 65 | new_ucmd!().arg(opt).run().stdout_is(expected_result(opt)); 66 | } 67 | } 68 | 69 | #[cfg(target_os = "linux")] 70 | fn expected_result(arg: &str) -> String { 71 | TestScenario::new(util_name!()).cmd_keepenv(util_name!()).args(&[arg]).run().stdout 72 | } 73 | -------------------------------------------------------------------------------- /src/printf/tokenize/num_format/formatters/base_conv/tests.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | 3 | use super::*; 4 | 5 | #[test] 6 | fn test_arrnum_int_mult() { 7 | // (in base 10) 12 * 4 = 48 8 | let factor: Vec = vec![1, 2]; 9 | let base_num = 10; 10 | let base_ten_int_fact: u8 = 4; 11 | let should_output: Vec = vec![4, 8]; 12 | 13 | let product = arrnum_int_mult(&factor, base_num, base_ten_int_fact); 14 | assert!(product == should_output); 15 | } 16 | 17 | #[test] 18 | fn test_arrnum_int_non_base_10() { 19 | // (in base 3) 20 | // 5 * 4 = 20 21 | let factor: Vec = vec![1, 2]; 22 | let base_num = 3; 23 | let base_ten_int_fact: u8 = 4; 24 | let should_output: Vec = vec![2, 0, 2]; 25 | 26 | let product = arrnum_int_mult(&factor, base_num, base_ten_int_fact); 27 | assert!(product == should_output); 28 | } 29 | 30 | #[test] 31 | fn test_arrnum_int_div_shortcircuit() { 32 | // ( 33 | let arrnum: Vec = vec![5, 5, 5, 5, 0]; 34 | let base_num = 10; 35 | let base_ten_int_divisor: u8 = 41; 36 | let remainder_passed_in = Remainder { 37 | position: 1, 38 | replace: vec![1, 3], 39 | arr_num: &arrnum, 40 | }; 41 | 42 | // the "replace" should mean the number being divided 43 | // is 1350, the first time you can get 41 to go into 44 | // 1350, its at 135, where you can get a quotient of 45 | // 3 and a remainder of 12; 46 | 47 | let quotient_should_be: u8 = 3; 48 | let remainder_position_should_be: usize = 3; 49 | let remainder_replace_should_be = vec![1, 2]; 50 | 51 | let result = arrnum_int_div_step(remainder_passed_in, base_num, base_ten_int_divisor, false); 52 | assert!(quotient_should_be == result.quotient); 53 | assert!(remainder_position_should_be == result.remainder.position); 54 | assert!(remainder_replace_should_be == result.remainder.replace); 55 | } 56 | -------------------------------------------------------------------------------- /src/whoami/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 | extern crate getopts; 15 | 16 | #[macro_use] 17 | extern crate uucore; 18 | 19 | use getopts::Options; 20 | use std::io::Write; 21 | 22 | mod platform; 23 | 24 | static NAME: &'static str = "whoami"; 25 | static VERSION: &'static str = env!("CARGO_PKG_VERSION"); 26 | 27 | pub fn uumain(args: Vec) -> i32 { 28 | let mut opts = Options::new(); 29 | 30 | opts.optflag("h", "help", "display this help and exit"); 31 | opts.optflag("V", "version", "output version information and exit"); 32 | 33 | let matches = match opts.parse(&args[1..]) { 34 | Ok(m) => m, 35 | Err(f) => crash!(1, "{}", f), 36 | }; 37 | if matches.opt_present("help") { 38 | println!("{} {}", NAME, VERSION); 39 | println!(""); 40 | println!("Usage:"); 41 | println!(" {} [OPTIONS]", NAME); 42 | println!(""); 43 | println!("{}", opts.usage("print effective userid")); 44 | return 0; 45 | } 46 | if matches.opt_present("version") { 47 | println!("{} {}", NAME, VERSION); 48 | return 0; 49 | } 50 | 51 | exec(); 52 | 53 | 0 54 | } 55 | 56 | pub fn exec() { 57 | unsafe { 58 | match platform::getusername() { 59 | Ok(username) => println!("{}", username), 60 | Err(err) => match err.raw_os_error() { 61 | Some(0) | None => crash!(1, "failed to get username"), 62 | Some(_) => crash!(1, "failed to get username: {}", err), 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | matrix: 3 | - TARGET: x86_64-pc-windows-msvc 4 | - TARGET: i686-pc-windows-msvc 5 | - TARGET: i686-pc-windows-gnu 6 | MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/dwarf/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z/download 7 | MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z 8 | MINGW_DIR: mingw32 9 | DIR_TEMP_MINGW: C:\cached\mingw 10 | - TARGET: x86_64-pc-windows-gnu 11 | MSYS_BITS: 64 12 | 13 | install: 14 | - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" 15 | - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin;C:\MinGW\bin 16 | 17 | # Use the system msys if we can 18 | - if defined MSYS_BITS set PATH=C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH% 19 | 20 | - ps: >- 21 | if ((Test-Path Env:\MINGW_ARCHIVE) -and -not (Test-Path "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}")) { 22 | if (Test-Path "${env:DIR_TEMP_MINGW}") { 23 | rm -Recurse ${env:DIR_TEMP_MINGW}\*; 24 | } 25 | New-Item -ItemType Directory -Force -Path ${env:DIR_TEMP_MINGW} | Out-Null; 26 | $download_loc = ${env:MINGW_URL}; 27 | Start-FileDownload $download_loc -FileName "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}"; 28 | } 29 | - if defined MINGW_ARCHIVE 7z x -y "%DIR_TEMP_MINGW%\%MINGW_ARCHIVE%" > nul 30 | - if defined MINGW_ARCHIVE set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH% 31 | 32 | - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" 33 | 34 | - rustc -V 35 | - cargo -V 36 | 37 | artifacts: 38 | - path: target\debug\uutils.exe 39 | name: uutils.exe 40 | 41 | build: false 42 | 43 | test_script: 44 | - cargo test --no-fail-fast --features "nightly generic" --no-default-features 45 | 46 | cache: 47 | - c:\cached 48 | -------------------------------------------------------------------------------- /tests/test_env.rs: -------------------------------------------------------------------------------- 1 | use common::util::*; 2 | 3 | 4 | #[test] 5 | fn test_single_name_value_pair() { 6 | let out = new_ucmd!() 7 | .arg("FOO=bar").run().stdout; 8 | 9 | assert!(out.lines().any(|line| line == "FOO=bar")); 10 | } 11 | 12 | #[test] 13 | fn test_multiple_name_value_pairs() { 14 | let out = new_ucmd!() 15 | .arg("FOO=bar") 16 | .arg("ABC=xyz") 17 | .run() 18 | .stdout; 19 | 20 | assert_eq!(out.lines().filter(|&line| line == "FOO=bar" || line == "ABC=xyz").count(), 21 | 2); 22 | } 23 | 24 | #[test] 25 | fn test_ignore_environment() { 26 | let scene = TestScenario::new(util_name!()); 27 | 28 | let out = scene.ucmd() 29 | .arg("-i") 30 | .run() 31 | .stdout; 32 | 33 | assert_eq!(out, ""); 34 | 35 | let out = scene.ucmd() 36 | .arg("-") 37 | .run() 38 | .stdout; 39 | 40 | assert_eq!(out, ""); 41 | } 42 | 43 | #[test] 44 | fn test_null_delimiter() { 45 | let out = new_ucmd!() 46 | .arg("-i") 47 | .arg("--null") 48 | .arg("FOO=bar") 49 | .arg("ABC=xyz") 50 | .run() 51 | .stdout; 52 | 53 | let mut vars : Vec<_> = out.split('\0').collect(); 54 | assert_eq!(vars.len(), 3); 55 | vars.sort(); 56 | assert_eq!(vars[0], ""); 57 | assert_eq!(vars[1], "ABC=xyz"); 58 | assert_eq!(vars[2], "FOO=bar"); 59 | } 60 | 61 | #[test] 62 | fn test_unset_variable() { 63 | // This test depends on the HOME variable being pre-defined by the 64 | // default shell 65 | let out = TestScenario::new(util_name!()) 66 | .ucmd_keepenv() 67 | .arg("-u") 68 | .arg("HOME") 69 | .run() 70 | .stdout; 71 | 72 | assert_eq!(out.lines().any(|line| line.starts_with("HOME=")), false); 73 | } 74 | --------------------------------------------------------------------------------