...
 
Commits (225)
# spell-checker:words POSIX repo SDK SDKs toolchain toolchains
# spell-checker:ignore uutils ARCH ABI BACKTRACE BINDIR cl COMNTOOLS dllcrt findstr maint MINGW MINGWDIR mkdir MSVC MSYS rustc rustlib rustup USERPROFILE vcvarsall
version: "{build} ~ {branch}"
branches:
except:
- gh-pages
os: Visual Studio 2015
artifacts:
- path: target\%TARGET%\debug\uutils.exe
name: uutils.exe
matrix:
allow_failures:
- CHANNEL: nightly
# - ABI: gnu
environment:
global:
FEATURES: "generic"
BUILD_OPTIONS: "--no-default-features"
TEST_OPTIONS: "--no-default-features --no-fail-fast"
matrix:
# minimum version
- CHANNEL: 1.27.0
ARCH: i686
ABI: msvc
# "msvc" ABI
- CHANNEL: stable
ARCH: i686
ABI: msvc
- CHANNEL: stable
ARCH: x86_64
ABI: msvc
# - CHANNEL: beta
# ARCH: i686
# ABI: msvc
# - CHANNEL: beta
# ARCH: x86_64
# ABI: msvc
- CHANNEL: nightly
ARCH: i686
ABI: msvc
FEATURES: "generic nightly"
- CHANNEL: nightly
ARCH: x86_64
ABI: msvc
FEATURES: "generic nightly"
# "gnu" ABI
- CHANNEL: stable
ARCH: i686
ABI: gnu
- CHANNEL: stable
ARCH: x86_64
ABI: gnu
# - CHANNEL: beta
# ARCH: i686
# ABI: gnu
# - CHANNEL: beta
# ARCH: x86_64
# ABI: gnu
# - CHANNEL: nightly
# ARCH: i686
# ABI: gnu
# - CHANNEL: nightly
# ARCH: x86_64
# ABI: gnu
# * specific gnu compilers
- CHANNEL: stable
ARCH: i686
ABI: gnu
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
MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z
- CHANNEL: stable
ARCH: x86_64
ABI: gnu
MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z/download#mingw-w64-x86_64-7.3.0-posix-seh.7z
install:
# force branch checkout (if knowable), then reset to the specific commit ## (can be needed for accurate code coverage info)
# * this allows later apps to see the branch name using standard `git branch` operations, yet always builds the correct specific commit
# * ref: <https://github.com/appveyor/ci/issues/1606>[`@`](https://archive.is/RVpnF)
- if DEFINED APPVEYOR_REPO_BRANCH if /I "%APPVEYOR_REPO_SCM%"=="git" ( git checkout "%APPVEYOR_REPO_BRANCH%" 2>NUL & git reset --hard "%APPVEYOR_REPO_COMMIT%" )
# ensure CWD is project main directory
- cd "%APPVEYOR_BUILD_FOLDER%"
# create a working area
- ps: if ( ! $env:CI_TEMP_DIR ) { $env:CI_TEMP_DIR = "${env:TEMP}\${env:APPVEYOR_JOB_ID}" ; mkdir -force $env:CI_TEMP_DIR | out-null }
# define the TARGET host
- set "TARGET=%ARCH%-pc-windows-%ABI%"
# show relevant environment settings
- ps: ('CHANNEL', 'ARCH', 'ABI', 'FEATURES', 'BUILD_OPTIONS', 'TEST_OPTIONS', 'TARGET') |% { write-host -f yellow "$_=$(get-content -ea silent env:/$_)" }
# rust installation
# * install `rust` via `rustup`
- appveyor DownloadFile "https://win.rustup.rs/" -FileName "%CI_TEMP_DIR%\rustup-init.exe"
- call "%CI_TEMP_DIR%\rustup-init.exe" -y --default-toolchain %CHANNEL% --default-host %TARGET% --no-modify-path >NUL
- set "PATH=%PATH%;%USERPROFILE%\.cargo\bin"
- ps: $env:TOOLCHAIN = $("$(rustup show active-toolchain)" -split '\s+')[0]
# * set RUST_BACKTRACE for enhanced error messages
- set RUST_BACKTRACE=1
# * show rust versions
- rustc -vV
- cargo -vV
# "gnu" ABI setup
# * use the system MinGW/MSYS if we can
- if /i "%ABI%"=="gnu" set MSYS_BINDIR=C:\msys64\usr\bin
- if /i "%ABI%"=="gnu" if /i "%ARCH%"=="i686" set "MSYS_BITS=32"
- if /i "%ABI%"=="gnu" if /i "%ARCH%"=="x86_64" set "MSYS_BITS=64"
- if defined MSYS_BITS set "MSYS_MINGWDIR=C:\msys64\mingw%MSYS_BITS%"
- if defined MSYS_MINGWDIR set "MSYS_BINDIR=C:\msys64\usr\bin"
## * workaround for rust-lang/rust#47048 / rust-lang/rust#53454 ## !maint: remove when resolved
- if /i "%ABI%"=="gnu" if /i "%ARCH%"=="i686" if not DEFINED MINGW_URL set "MINGW_URL=https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/mingw-builds/8.1.0/threads-posix/dwarf/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z"
- if /i "%ABI%"=="gnu" if /i "%ARCH%"=="x86_64" if not DEFINED MINGW_URL set "MINGW_URL=https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z"
## (end workaround)
# * specific MinGW, if specified
- ps: if ( ! $env:MINGW_ARCHIVE -and $env:MINGW_URL ) { $env:MINGW_ARCHIVE = $($([URI]$env:MINGW_URL).fragment).TrimStart('#') }
- ps: if ( ! $env:MINGW_ARCHIVE -and $env:MINGW_URL ) { $env:MINGW_ARCHIVE = $([URI]$env:MINGW_URL).segments[-1] }
- if defined MINGW_ARCHIVE curl --insecure -fsSL "%MINGW_URL%" -o "%CI_TEMP_DIR%\%MINGW_ARCHIVE%"
- if defined MINGW_ARCHIVE mkdir "%CI_TEMP_DIR%\MinGW" >NUL
- if defined MINGW_ARCHIVE 7z x -y "%CI_TEMP_DIR%\%MINGW_ARCHIVE%" -o"%CI_TEMP_DIR%\MinGW" >NUL
- if defined MINGW_ARCHIVE set "MSYS_MINGWDIR=%CI_TEMP_DIR%\MinGW\mingw%MSYS_BITS%"
- if defined MINGW_ARCHIVE set "MSYS_BINDIR=%MSYS_MINGWDIR%\bin"
# * MinGW/MSYS PATH setup
- if defined MSYS_MINGWDIR set PATH=%MSYS_MINGWDIR%\%ARCH%-w64-mingw32\bin;%MSYS_BINDIR%;%PATH%
## * workaround for rust-lang/rust#47048 / rust-lang/rust#53454 ## !maint: remove when resolved
# ** ref: <https://github.com/rust-lang/rust/issues/47048>, <https://github.com/rust-lang/rust/issues/53454>
# ** egs: <https://github.com/pkgw/tectonic/commit/29686db533d8732d7d97fc94270ed33b77f29295>, <https://github.com/rukai/PF_Sandbox/blob/e842613cf9ff102dfb3fbd87381319e6e6dfe3ae/appveyor.yml>
- if /i "%ABI%"=="gnu" rustup install %CHANNEL%-%ARCH%-pc-windows-msvc
- if /i "%ABI%"=="gnu" rustup default %CHANNEL%-%ARCH%-pc-windows-msvc
- if /i "%ABI%"=="gnu" rustup target add %TARGET%
- ps: $env:TOOLCHAIN = $("$(rustup show active-toolchain)" -split '\s+')[0]
- if /i "%ABI%"=="gnu" rustup show
- if /i "%ABI%"=="gnu" rustc -vV
# ** copy libs from gcc toolchain to rust toolchain (more specifically, "crt2.o" and "dllcrt2.o" are needed)
- if defined MSYS_MINGWDIR copy /y "%MSYS_MINGWDIR%\%ARCH%-w64-mingw32\lib\*.o" "%USERPROFILE%\.rustup\toolchains\%TOOLCHAIN%\lib\rustlib\%TARGET%\lib" >NUL
## (end workaround)
# * show `gcc` info
- if /i "%ABI%"=="gnu" ( where gcc && gcc --version )
# "msvc" ABI setup
- if /i "%ABI%" == "msvc" if /i "%ARCH%" == "i686" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat"
- if /i "%ABI%" == "msvc" if /i "%ARCH%" == "x86_64" call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
- if /i "%ABI%" == "msvc" if /i "%ARCH%" == "x86_64" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
# * show `cl` info
- if /i "%ABI%"=="msvc" ( where cl && cl 2>&1 | findstr /i /c:"version" )
# finalize options
- ps: if ("$env:FEATURES".length) { $env:BUILD_OPTIONS = $(($env:BUILD_OPTIONS, "--features `"${env:FEATURES}`"")|?{$_}) -join ' ' }
- ps: if ("$env:FEATURES".length) { $env:TEST_OPTIONS = $(($env:TEST_OPTIONS, "--features `"${env:FEATURES}`"")|?{$_}) -join ' ' }
build_script:
- ps: $env:BUILD_CMD = $(("cargo +${env:TOOLCHAIN} build --target=${env:TARGET}", $env:BUILD_OPTIONS)|?{$_}) -join ' '
- echo [ `%BUILD_CMD%` ] & %BUILD_CMD%
test_script:
- ps: $env:TEST_CMD = $(("cargo +${env:TOOLCHAIN} test --target=${env:TARGET}", $env:TEST_OPTIONS)|?{$_}) -join ' '
- echo [ `%TEST_CMD%` ] & %TEST_CMD%
comment: false
language: rust
rust:
- stable
- beta
os:
- linux
- osx
env:
# sphinx v1.8.0 is bugged & fails for linux builds; so, force specfic `sphinx` version
global: FEATURES='' TEST_INSTALL='' SPHINX_VERSIONED='sphinx==1.7.8'
matrix:
allow_failures:
- rust: nightly
fast_finish: true
include:
- rust: 1.27.0
- rust: stable
os: linux
env: FEATURES=''
env: TEST_INSTALL=true
- rust: stable
os: osx
env: FEATURES=''
- rust: beta
os: linux
env: FEATURES=''
- rust: beta
os: osx
env: FEATURES=''
env: TEST_INSTALL=true
- rust: nightly
os: linux
env: FEATURES=nightly
......@@ -23,10 +33,6 @@ matrix:
- rust: nightly
os: linux
env: FEATURES=nightly,redox CC=x86_64-unknown-redox-gcc CARGO_ARGS='--no-default-features --target=x86_64-unknown-redox' REDOX=1
allow_failures:
- rust: nightly
os: linux
env: FEATURES=nightly,redox CC=x86_64-unknown-redox-gcc CARGO_ARGS='--no-default-features --target=x86_64-unknown-redox' REDOX=1
cache:
directories:
......@@ -37,9 +43,19 @@ sudo: true
before_install:
- if [ $REDOX ]; then ./.travis/redox-toolchain.sh; fi
install:
- if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install python-pip && sudo pip install $SPHINX_VERSIONED; fi
- |
if [ $TRAVIS_OS_NAME = osx ]; then
brew update
brew upgrade python
pip3 install $SPHINX_VERSIONED
fi
script:
- cargo build $CARGO_ARGS --features "$FEATURES"
- if [ ! $REDOX ]; then cargo test $CARGO_ARGS --features "$FEATURES" --no-fail-fast; fi
- if [ -n "$TEST_INSTALL" ]; then mkdir installdir_test; DESTDIR=installdir_test make install; [ `ls installdir_test/usr/local/bin | wc -l` -gt 0 ]; fi
addons:
apt:
......@@ -52,4 +68,3 @@ after_success: |
cargo tarpaulin --out Xml
bash <(curl -s https://codecov.io/bash)
fi
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,6 +3,7 @@ name = "uutils"
version = "0.0.1"
authors = []
build = "build.rs"
autotests = false
[features]
unix = [
......@@ -55,7 +56,6 @@ fuchsia = [
"nice",
"pathchk",
"stdbuf",
"touch",
"tty",
"uname",
"unlink",
......@@ -68,6 +68,7 @@ generic = [
"hostname",
"nproc",
"sync",
"touch",
"whoami",
"redox_generic"
]
......@@ -249,14 +250,14 @@ whoami = { optional=true, path="src/whoami" }
yes = { optional=true, path="src/yes" }
[dev-dependencies]
time = "0.1.38"
filetime = "0.1.10"
libc = "0.2.26"
regex = "0.2.2"
rand = "0.3.15"
tempdir = "0.3.5"
unindent = "0.1.0"
lazy_static = "0.2.2"
time = "0.1.42"
filetime = "0.2.5"
libc = "0.2.51"
regex = "1.0.3"
rand = "0.6.5"
tempdir = "0.3.7"
unindent = "0.1.3"
lazy_static = "1.3.0"
[target.'cfg(unix)'.dev-dependencies]
rust-users = { git = "https://github.com/uutils/rust-users" }
......@@ -268,3 +269,6 @@ path = "src/uutils/uutils.rs"
[[test]]
name = "tests"
[patch.crates-io]
tempfile = { git = "https://gitlab.redox-os.org/redox-os/tempfile", branch = "redox-unix" }
......@@ -21,11 +21,9 @@ CARGOFLAGS ?=
PREFIX ?= /usr/local
DESTDIR ?=
BINDIR ?= /bin
LIBDIR ?= /lib
MANDIR ?= /man/man1
INSTALLDIR_BIN=$(DESTDIR)$(PREFIX)$(BINDIR)
INSTALLDIR_LIB=$(DESTDIR)$(PREFIX)$(LIBDIR)
INSTALLDIR_MAN=$(DESTDIR)$(PREFIX)/share/$(MANDIR)
$(shell test -d $(INSTALLDIR_MAN))
ifneq ($(.SHELLSTATUS),0)
......@@ -248,12 +246,6 @@ ifeq ($(SYSTEM),Darwin)
DYLIB_FLAGS := -dynamiclib -undefined dynamic_lookup
endif
# Libaries to install
LIBS :=
ifneq (,$(findstring stdbuf, $(INSTALLEES)))
LIBS += libstdbuf.$(DYLIB_EXT)
endif
all: build
do_install = $(INSTALL) ${1}
......@@ -308,7 +300,6 @@ distclean: clean
install: build
mkdir -p $(INSTALLDIR_BIN)
mkdir -p $(INSTALLDIR_LIB)
mkdir -p $(INSTALLDIR_MAN)
ifeq (${MULTICALL}, y)
$(INSTALL) $(BUILDDIR)/uutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)uutils
......@@ -319,7 +310,6 @@ else
$(foreach prog, $(INSTALLEES), \
$(INSTALL) $(BUILDDIR)/$(prog) $(INSTALLDIR_BIN)/$(PROG_PREFIX)$(prog);)
endif
$(foreach lib, $(LIBS), $(INSTALL) $(BUILDDIR)/build/*/out/$(lib) $(INSTALLDIR_LIB)/$(PROG_PREFIX)$(lib) &&) :
$(foreach man, $(filter $(INSTALLEES), $(basename $(notdir $(wildcard $(DOCSDIR)/_build/man/*)))), \
cat $(DOCSDIR)/_build/man/$(man).1 | gzip > $(INSTALLDIR_MAN)/$(PROG_PREFIX)$(man).1.gz &&) :
......@@ -330,6 +320,5 @@ endif
rm -f $(addprefix $(INSTALLDIR_MAN)/,$(PROG_PREFIX)uutils.1.gz)
rm -f $(addprefix $(INSTALLDIR_BIN)/$(PROG_PREFIX),$(PROGS))
rm -f $(addprefix $(INSTALLDIR_MAN)/$(PROG_PREFIX),$(addsuffix .1.gz,$(PROGS)))
rm -f $(addprefix $(INSTALLDIR_LIB)/$(PROG_PREFIX),$(LIBS))
.PHONY: all build build-uutils build-pkgs build-docs test distclean clean busytest install uninstall
......@@ -4,8 +4,8 @@ uutils coreutils
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/uutils/coreutils/blob/master/LICENSE)
[![Build Status](https://api.travis-ci.org/uutils/coreutils.svg?branch=master)](https://travis-ci.org/uutils/coreutils)
[![Build status](https://ci.appveyor.com/api/projects/status/787ltcxgy86r20le?svg=true)](https://ci.appveyor.com/project/Arcterus/coreutils)
[![codecov](https://codecov.io/gh/uutils/coreutils/branch/master/graph/badge.svg)](https://codecov.io/gh/uutils/coreutils)
[![LOC](https://tokei.rs/b1/github/uutils/coreutils?category=code)](https://github.com/Aaronepower/tokei)
[![dependency status](https://deps.rs/repo/github/uutils/coreutils/status.svg)](https://deps.rs/repo/github/uutils/coreutils)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fuutils%2Fcoreutils.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fuutils%2Fcoreutils?ref=badge_shield)
uutils is an attempt at writing universal (as in cross-platform) CLI
......@@ -36,7 +36,7 @@ Requirements
### Rust Version ###
uutils follows Rust's release channels and is tested against stable, beta and nightly.
The current oldest supported version of the Rust compiler is `1.22.0`.
The current oldest supported version of the Rust compiler is `1.27.0`.
On both Windows and Redox, only the nightly version is tested currently.
......@@ -62,6 +62,14 @@ every other Rust program:
$ cargo build --release
```
Because the above command attempts to build utilities that only work on
Unix-like platforms at the moment, to build on Windows, you must do the
following:
```bash
# to keep debug information, compile without --release
$ cargo build --release --no-default-features --features generic
```
If you don't want to build every utility available on your platform into the
multicall binary (the Busybox-esque binary), you can also specify which ones
you want to build manually. For example:
......
os: Visual Studio 2015
environment:
matrix:
- TARGET: x86_64-pc-windows-msvc
MSYS_BITS: 64
TOOLCHAIN: msvc
PLATFORM: x86_64
- TARGET: i686-pc-windows-msvc
MSYS_BITS: 32
TOOLCHAIN: msvc
PLATFORM: i686
- TARGET: i686-pc-windows-gnu
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
MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z
MINGW_DIR: mingw32
DIR_TEMP_MINGW: C:\cached\mingw
- TARGET: x86_64-pc-windows-gnu
MSYS_BITS: 64
install:
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin;C:\MinGW\bin
# Use the system msys if we can
- if defined MSYS_BITS set PATH=C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH%
- ps: >-
Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe";
if ((Test-Path Env:\MINGW_ARCHIVE) -and -not (Test-Path "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}")) {
if (Test-Path "${env:DIR_TEMP_MINGW}") {
rm -Recurse ${env:DIR_TEMP_MINGW}\*;
}
New-Item -ItemType Directory -Force -Path ${env:DIR_TEMP_MINGW} | Out-Null;
$download_loc = ${env:MINGW_URL};
Start-FileDownload $download_loc -FileName "${env:DIR_TEMP_MINGW}\${env:MINGW_ARCHIVE}";
}
- if defined MINGW_ARCHIVE 7z x -y "%DIR_TEMP_MINGW%\%MINGW_ARCHIVE%" > nul
- if defined MINGW_ARCHIVE set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH%
- rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
- rustc -V
- cargo -V
- if "%TOOLCHAIN%" == "msvc" if "%PLATFORM%" == "i686" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat"
- if "%TOOLCHAIN%" == "msvc" if "%PLATFORM%" == "x86_64" "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
- if "%TOOLCHAIN%" == "msvc" if "%PLATFORM%" == "x86_64" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
artifacts:
- path: target\debug\uutils.exe
name: uutils.exe
build: false
test_script:
- cargo test --no-fail-fast --features "nightly generic" --no-default-features
cache:
- c:\cached
coverage:
status:
project:
default:
# TODO: when the embedding interface is complete, this should be
# changed to something more reasonable, like 1%
threshold: 50%
......@@ -13,7 +13,7 @@ use uu_@UTIL_CRATE@::uumain;
fn main() {
uucore::panic::install_sigpipe_hook();
let code = uumain(std::env::args().collect());
let code = uumain(uucore::args().collect());
// Since stdout is line-buffered by default, we need to ensure any pending
// writes are flushed before exiting. Ideally, this should be enforced by
// each utility.
......
......@@ -9,7 +9,7 @@ name = "uu_arch"
path = "arch.rs"
[dependencies]
platform-info = { git = "https://github.com/uutils/platform-info" }
platform-info = { git = "https://gitlab.redox-os.org/redox-os/platform-info.git", branch = "redox-unix" }
uucore = { path = "../uucore" }
[[bin]]
......
......@@ -15,9 +15,9 @@ extern crate uucore;
use platform_info::*;
static SYNTAX: &'static str = "";
static SUMMARY: &'static str = "Determine architecture name for current machine.";
static LONG_HELP: &'static str = "";
static SYNTAX: &str = "";
static SUMMARY: &str = "Determine architecture name for current machine.";
static LONG_HELP: &str = "";
pub fn uumain(args: Vec<String>) -> i32 {
new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
......
......@@ -13,7 +13,7 @@ path = "../uucore"
features = ["encoding"]
[dependencies.clippy]
version = "0.0.143"
version = "0.0.212"
optional = true
[[bin]]
......
......@@ -10,16 +10,15 @@
#[macro_use]
extern crate uucore;
use uucore::encoding::{wrap_print, Data, Format};
use uucore::encoding::Format;
use std::fs::File;
use std::io::{stdin, BufReader, Read};
use std::path::Path;
#[path = "../base64/base_common.rs"]
mod base_common;
static SYNTAX: &'static str = "[OPTION]... [FILE]";
static SUMMARY: &'static str =
static SYNTAX: &str = "[OPTION]... [FILE]";
static SUMMARY: &str =
"Base32 encode or decode FILE, or standard input, to standard output.";
static LONG_HELP: &'static str = "
static LONG_HELP: &str = "
With no FILE, or when FILE is -, read standard input.
The data are encoded as described for the base32 alphabet in RFC
......@@ -30,56 +29,5 @@ static LONG_HELP: &'static str = "
";
pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
.optflag("d", "decode", "decode data")
.optflag(
"i",
"ignore-garbage",
"when decoding, ignore non-alphabetic characters",
)
.optopt(
"w",
"wrap",
"wrap encoded lines after COLS character (default 76, 0 to disable wrapping)",
"COLS",
)
.parse(args);
let line_wrap = match matches.opt_str("wrap") {
Some(s) => match s.parse() {
Ok(n) => n,
Err(e) => {
crash!(1, "invalid wrap size: ‘{}’: {}", s, e);
}
},
None => 76,
};
if matches.free.len() > 1 {
disp_err!("extra operand ‘{}’", matches.free[0]);
return 1;
}
let input = if matches.free.is_empty() || &matches.free[0][..] == "-" {
BufReader::new(Box::new(stdin()) as Box<Read>)
} else {
let path = Path::new(matches.free[0].as_str());
let file_buf = safe_unwrap!(File::open(&path));
BufReader::new(Box::new(file_buf) as Box<Read>)
};
let mut data = Data::new(input, Format::Base32)
.line_wrap(line_wrap)
.ignore_garbage(matches.opt_present("ignore-garbage"));
if !matches.opt_present("decode") {
wrap_print(line_wrap, data.encode());
} else {
match data.decode() {
Ok(s) => print!("{}", String::from_utf8(s).unwrap()),
Err(_) => crash!(1, "invalid input"),
}
}
0
base_common::execute(args, SYNTAX, SUMMARY, LONG_HELP, Format::Base32)
}
......@@ -11,16 +11,14 @@
#[macro_use]
extern crate uucore;
use uucore::encoding::{wrap_print, Data, Format};
use uucore::encoding::Format;
use std::fs::File;
use std::io::{stdin, BufReader, Read};
use std::path::Path;
mod base_common;
static SYNTAX: &'static str = "[OPTION]... [FILE]";
static SUMMARY: &'static str =
static SYNTAX: &str = "[OPTION]... [FILE]";
static SUMMARY: &str =
"Base64 encode or decode FILE, or standard input, to standard output.";
static LONG_HELP: &'static str = "
static LONG_HELP: &str = "
With no FILE, or when FILE is -, read standard input.
The data are encoded as described for the base64 alphabet in RFC
......@@ -31,56 +29,5 @@ static LONG_HELP: &'static str = "
";
pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
.optflag("d", "decode", "decode data")
.optflag(
"i",
"ignore-garbage",
"when decoding, ignore non-alphabetic characters",
)
.optopt(
"w",
"wrap",
"wrap encoded lines after COLS character (default 76, 0 to disable wrapping)",
"COLS",
)
.parse(args);
let line_wrap = match matches.opt_str("wrap") {
Some(s) => match s.parse() {
Ok(n) => n,
Err(e) => {
crash!(1, "invalid wrap size: ‘{}’: {}", s, e);
}
},
None => 76,
};
if matches.free.len() > 1 {
disp_err!("extra operand ‘{}’", matches.free[0]);
return 1;
}
let input = if matches.free.is_empty() || &matches.free[0][..] == "-" {
BufReader::new(Box::new(stdin()) as Box<Read>)
} else {
let path = Path::new(matches.free[0].as_str());
let file_buf = safe_unwrap!(File::open(&path));
BufReader::new(Box::new(file_buf) as Box<Read>)
};
let mut data = Data::new(input, Format::Base64)
.line_wrap(line_wrap)
.ignore_garbage(matches.opt_present("ignore-garbage"));
if !matches.opt_present("decode") {
wrap_print(line_wrap, data.encode());
} else {
match data.decode() {
Ok(s) => print!("{}", String::from_utf8(s).unwrap()),
Err(_) => crash!(1, "invalid input"),
}
}
0
base_common::execute(args, SYNTAX, SUMMARY, LONG_HELP, Format::Base64)
}
// This file is part of the uutils coreutils package.
//
// (c) Jordy Dickinson <jordy.dickinson@gmail.com>
// (c) Jian Zeng <anonymousknight96@gmail.com>
// (c) Alex Lyon <arcterus@mail.com>
//
// For the full copyright and license information, please view the LICENSE file
// that was distributed with this source code.
//
use uucore;
use uucore::encoding::{wrap_print, Data, Format};
use std::fs::File;
use std::io::{stdin, BufReader, Read};
use std::path::Path;
pub fn execute(
args: Vec<String>,
syntax: &str,
summary: &str,
long_help: &str,
format: Format,
) -> i32 {
let matches = new_coreopts!(syntax, summary, long_help)
.optflag("d", "decode", "decode data")
.optflag(
"i",
"ignore-garbage",
"when decoding, ignore non-alphabetic characters",
)
.optopt(
"w",
"wrap",
"wrap encoded lines after COLS character (default 76, 0 to disable wrapping)",
"COLS",
)
.parse(args);
let line_wrap = matches.opt_str("wrap").map(|s| {
match s.parse() {
Ok(n) => n,
Err(e) => {
crash!(1, "invalid wrap size: ‘{}’: {}", s, e);
}
}
});
let ignore_garbage = matches.opt_present("ignore-garbage");
let decode = matches.opt_present("decode");
if matches.free.len() > 1 {
disp_err!("extra operand ‘{}’", matches.free[0]);
return 1;
}
if matches.free.is_empty() || &matches.free[0][..] == "-" {
let stdin_raw = stdin();
handle_input(&mut stdin_raw.lock(), format, line_wrap, ignore_garbage, decode);
} else {
let path = Path::new(matches.free[0].as_str());
let file_buf = safe_unwrap!(File::open(&path));
let mut input = BufReader::new(file_buf);
handle_input(&mut input, format, line_wrap, ignore_garbage, decode);
};
0
}
fn handle_input<R: Read>(
input: &mut R,
format: Format,
line_wrap: Option<usize>,
ignore_garbage: bool,
decode: bool,
) {
let mut data = Data::new(input, format)
.ignore_garbage(ignore_garbage);
if let Some(wrap) = line_wrap {
data = data.line_wrap(wrap);
}
if !decode {
let encoded = data.encode();
wrap_print(&data, encoded);
} else {
match data.decode() {
Ok(s) => print!("{}", String::from_utf8(s).unwrap()),
Err(_) => crash!(1, "invalid input"),
}
}
}
\ No newline at end of file
......@@ -14,11 +14,11 @@ extern crate uucore;
use std::path::{is_separator, PathBuf};
static NAME: &'static str = "basename";
static SYNTAX: &'static str = "NAME [SUFFIX]";
static SUMMARY: &'static str = "Print NAME with any leading directory components removed
static NAME: &str = "basename";
static SYNTAX: &str = "NAME [SUFFIX]";
static SUMMARY: &str = "Print NAME with any leading directory components removed
If specified, also remove a trailing SUFFIX";
static LONG_HELP: &'static str = "";
static LONG_HELP: &str = "";
pub fn uumain(args: Vec<String>) -> i32 {
//
......@@ -44,7 +44,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
.parse(args);
// too few arguments
if matches.free.len() < 1 {
if matches.free.is_empty() {
crash!(
1,
"{0}: {1}\nTry '{0} --help' for more information.",
......
......@@ -9,7 +9,7 @@ name = "uu_cat"
path = "cat.rs"
[dependencies]
quick-error = "1.1.0"
quick-error = "1.2.2"
[dependencies.uucore]
path = "../uucore"
......
......@@ -31,10 +31,10 @@ use std::os::unix::fs::FileTypeExt;
#[cfg(unix)]
use unix_socket::UnixStream;
static SYNTAX: &'static str = "[OPTION]... [FILE]...";
static SUMMARY: &'static str = "Concatenate FILE(s), or standard input, to standard output
static SYNTAX: &str = "[OPTION]... [FILE]...";
static SUMMARY: &str = "Concatenate FILE(s), or standard input, to standard output
With no FILE, or when FILE is -, read standard input.";
static LONG_HELP: &'static str = "";
static LONG_HELP: &str = "";
#[derive(PartialEq)]
enum NumberingMode {
......@@ -174,32 +174,23 @@ pub fn uumain(args: Vec<String>) -> i32 {
let success = if can_write_fast {
write_fast(files).is_ok()
} else {
let tab = match show_tabs {
true => "^I",
false => "\t",
}.to_owned();
let tab = if show_tabs { "^I" } else { "\t" }.to_owned();
let end_of_line = match show_ends {
true => "$\n",
false => "\n",
}.to_owned();
let end_of_line = if show_ends { "$\n" } else { "\n" }.to_owned();
let options = OutputOptions {
end_of_line: end_of_line,
end_of_line,
number: number_mode,
show_nonprint: show_nonprint,
show_tabs: show_tabs,
squeeze_blank: squeeze_blank,
tab: tab,
show_nonprint,
show_tabs,
squeeze_blank,
tab,
};
write_lines(files, &options).is_ok()
};
match success {
true => 0,
false => 1,
}
if success { 0 } else { 1 }
}
/// Classifies the `InputType` of file at `path` if possible
......@@ -363,7 +354,7 @@ fn write_file_lines(file: &str, options: &OutputOptions, state: &mut OutputState
let mut pos = 0;
while pos < n {
// skip empty line_number enumerating them if needed
if in_buf[pos] == '\n' as u8 {
if in_buf[pos] == b'\n' {
if !state.at_line_start || !options.squeeze_blank || !one_blank_kept {
one_blank_kept = true;
if state.at_line_start && options.number == NumberingMode::NumberAll {
......@@ -415,7 +406,7 @@ fn write_file_lines(file: &str, options: &OutputOptions, state: &mut OutputState
// Write all symbols till end of line or end of buffer is reached
// Return the (number of written symbols + 1) or 0 if the end of buffer is reached
fn write_to_end<W: Write>(in_buf: &[u8], writer: &mut W) -> usize {
match in_buf.iter().position(|c| *c == '\n' as u8) {
match in_buf.iter().position(|c| *c == b'\n') {
Some(p) => {
writer.write_all(&in_buf[..p]).unwrap();
p + 1
......@@ -428,18 +419,20 @@ fn write_to_end<W: Write>(in_buf: &[u8], writer: &mut W) -> usize {
}
fn write_tab_to_end<W: Write>(mut in_buf: &[u8], writer: &mut W) -> usize {
let mut count = 0;
loop {
match in_buf
.iter()
.position(|c| *c == '\n' as u8 || *c == '\t' as u8)
.position(|c| *c == b'\n' || *c == b'\t')
{
Some(p) => {
writer.write_all(&in_buf[..p]).unwrap();
if in_buf[p] == '\n' as u8 {
return p + 1;
if in_buf[p] == b'\n' {
return count + p + 1;
} else {
writer.write_all("^I".as_bytes()).unwrap();
writer.write_all(b"^I").unwrap();
in_buf = &in_buf[p + 1..];
count += p + 1;
}
}
None => {
......@@ -454,17 +447,17 @@ fn write_nonprint_to_end<W: Write>(in_buf: &[u8], writer: &mut W, tab: &[u8]) ->
let mut count = 0;
for byte in in_buf.iter().map(|c| *c) {
if byte == '\n' as u8 {
if byte == b'\n' {
break;
}
match byte {
9 => writer.write_all(tab),
0...8 | 10...31 => writer.write_all(&['^' as u8, byte + 64]),
0...8 | 10...31 => writer.write_all(&[b'^', byte + 64]),
32...126 => writer.write_all(&[byte]),
127 => writer.write_all(&['^' as u8, byte - 64]),
128...159 => writer.write_all(&['M' as u8, '-' as u8, '^' as u8, byte - 64]),
160...254 => writer.write_all(&['M' as u8, '-' as u8, byte - 128]),
_ => writer.write_all(&['M' as u8, '-' as u8, '^' as u8, 63]),
127 => writer.write_all(&[b'^', byte - 64]),
128...159 => writer.write_all(&[b'M', b'-', b'^', byte - 64]),
160...254 => writer.write_all(&[b'M', b'-', byte - 128]),
_ => writer.write_all(&[b'M', b'-', b'^', 63]),
}.unwrap();
count += 1;
}
......
......@@ -9,7 +9,7 @@ name = "uu_chgrp"
path = "chgrp.rs"
[dependencies]
walkdir = "1.0.7"
walkdir = "2.1.4"
[dependencies.uucore]
path = "../uucore"
......
......@@ -29,9 +29,9 @@ use std::path::Path;
use std::ffi::CString;
use std::os::unix::ffi::OsStrExt;
static SYNTAX: &'static str =
static SYNTAX: &str =
"chgrp [OPTION]... GROUP FILE...\n or : chgrp [OPTION]... --reference=RFILE FILE...";
static SUMMARY: &'static str = "Change the group of each FILE to GROUP.";
static SUMMARY: &str = "Change the group of each FILE to GROUP.";
const FTS_COMFOLLOW: u8 = 1;
const FTS_PHYSICAL: u8 = 1 << 1;
......@@ -117,7 +117,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
Verbosity::Normal
};
if matches.free.len() < 1 {
if matches.free.is_empty() {
disp_err!("missing operand");
return 1;
} else if matches.free.len() < 2 && !matches.opt_present("reference") {
......@@ -153,13 +153,13 @@ pub fn uumain(args: Vec<String>) -> i32 {
}
let executor = Chgrper {
bit_flag: bit_flag,
dest_gid: dest_gid,
verbosity: verbosity,
recursive: recursive,
bit_flag,
dest_gid,
verbosity,
recursive,
dereference: derefer != 0,
preserve_root: preserve_root,
files: files,
preserve_root,
files,
};
executor.exec()
}
......
......@@ -9,7 +9,7 @@ name = "uu_chmod"
path = "chmod.rs"
[dependencies]
libc = "0.2.26"
libc = "0.2.42"
walker = "1.0.0"
[dependencies.uucore]
......
......@@ -22,11 +22,12 @@ use std::path::Path;
use walker::Walker;
#[cfg(not(windows))]
use uucore::mode;
use uucore::fs::display_permissions_unix;
const NAME: &'static str = "chmod";
static SUMMARY: &'static str = "Change the mode of each FILE to MODE.
const NAME: &str = "chmod";
static SUMMARY: &str = "Change the mode of each FILE to MODE.
With --reference, change the mode of each FILE to that of RFILE.";
static LONG_HELP: &'static str = "
static LONG_HELP: &str = "
Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=]?[0-7]+'.
";
......@@ -38,11 +39,10 @@ pub fn uumain(mut args: Vec<String>) -> i32 {
NAME
);
let mut opts = new_coreopts!(&syntax, SUMMARY, LONG_HELP);
opts.optflag("c", "changes", "like verbose but report only when a change is made \
(unimplemented)")
opts.optflag("c", "changes", "like verbose but report only when a change is made")
// TODO: support --silent (can be done using clap)
.optflag("f", "quiet", "suppress most error messages (unimplemented)")
.optflag("v", "verbose", "output a diagnostic for every file processed (unimplemented)")
.optflag("f", "quiet", "suppress most error messages")
.optflag("v", "verbose", "output a diagnostic for every file processed")
.optflag("", "no-preserve-root", "do not treat '/' specially (the default)")
.optflag("", "preserve-root", "fail to operate recursively on '/'")
.optopt("", "reference", "use RFILE's mode instead of MODE values", "RFILE")
......@@ -81,13 +81,13 @@ pub fn uumain(mut args: Vec<String>) -> i32 {
None
};
let chmoder = Chmoder {
changes: changes,
quiet: quiet,
verbose: verbose,
preserve_root: preserve_root,
recursive: recursive,
fmode: fmode,
cmode: cmode,
changes,
quiet,
verbose,
preserve_root,
recursive,
fmode,
cmode,
};
match chmoder.chmod(matches.free) {
Ok(()) => {}
......@@ -184,7 +184,7 @@ impl Chmoder {
// instead it just sets the readonly attribute on the file
Err(0)
}
#[cfg(any(unix, target_os = "redox"))]
#[cfg(unix)]
fn chmod_file(&self, file: &Path, name: &str) -> Result<(), i32> {
let mut fperm = match fs::metadata(name) {
Ok(meta) => meta.mode() & 0o7777,
......@@ -226,10 +226,11 @@ impl Chmoder {
Ok(())
}
#[cfg(unix)]
fn change_file(&self, fperm: u32, mode: u32, file: &Path, path: &str) -> Result<(), i32> {
if fperm == mode {
if self.verbose && !self.changes {
show_info!("mode of '{}' retained as {:o}", file.display(), fperm);
show_info!("mode of '{}' retained as {:o} ({})", file.display(), fperm, display_permissions_unix(fperm));
}
Ok(())
} else if let Err(err) =
......@@ -240,20 +241,24 @@ impl Chmoder {
}
if self.verbose {
show_info!(
"failed to change mode of file '{}' from {:o} to {:o}",
"failed to change mode of file '{}' from {:o} ({}) to {:o} ({})",
file.display(),
fperm,
mode
display_permissions_unix(fperm),
mode,
display_permissions_unix(mode)
);
}
Err(1)
} else {
if self.verbose || self.changes {
show_info!(
"mode of '{}' changed from {:o} to {:o}",
"mode of '{}' changed from {:o} ({}) to {:o} ({})",
file.display(),
fperm,
mode
display_permissions_unix(fperm),
mode,
display_permissions_unix(mode)
);
}
Ok(())
......
......@@ -10,14 +10,14 @@ path = "chown.rs"
[dependencies]
glob = "0.2.11"
walkdir = "0.1"
walkdir = "2.1"
[dependencies.uucore]
path = "../uucore"
features = ["entries", "fs"]
[dependencies.clippy]
version = "0.0.143"
version = "0.0.212"
optional = true
[[bin]]
......
......@@ -30,9 +30,9 @@ use std::convert::AsRef;
use std::ffi::CString;
use std::os::unix::ffi::OsStrExt;
static SYNTAX: &'static str =
static SYNTAX: &str =
"[OPTION]... [OWNER][:[GROUP]] FILE...\n chown [OPTION]... --reference=RFILE FILE...";
static SUMMARY: &'static str = "change file owner and group";
static SUMMARY: &str = "change file owner and group";
const FTS_COMFOLLOW: u8 = 1;
const FTS_PHYSICAL: u8 = 1 << 1;
......@@ -136,7 +136,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
IfFrom::All
};
if matches.free.len() < 1 {
if matches.free.is_empty() {
disp_err!("missing operand");
return 1;
} else if matches.free.len() < 2 && !matches.opt_present("reference") {
......@@ -144,6 +144,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
return 1;
}
let mut files;
let dest_uid: Option<u32>;
let dest_gid: Option<u32>;
if let Some(file) = matches.opt_str("reference") {
......@@ -157,6 +158,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
return 1;
}
}
files = matches.free;
} else {
match parse_spec(&matches.free[0]) {
Ok((u, g)) => {
......@@ -168,19 +170,19 @@ pub fn uumain(args: Vec<String>) -> i32 {
return 1;
}
}
files = matches.free;
files.remove(0);
}
let mut files = matches.free;
files.remove(0);
let executor = Chowner {
bit_flag: bit_flag,
dest_uid: dest_uid,
dest_gid: dest_gid,
verbosity: verbosity,
recursive: recursive,
bit_flag,
dest_uid,
dest_gid,
verbosity,
recursive,
dereference: derefer != 0,
filter: filter,
preserve_root: preserve_root,
files: files,
filter,
preserve_root,
files,
};
executor.exec()
}
......
......@@ -9,7 +9,7 @@ name = "uu_chroot"
path = "chroot.rs"
[dependencies]
getopts = "0.2.14"
getopts = "0.2.18"
[dependencies.uucore]
path = "../uucore"
......
......@@ -23,10 +23,10 @@ use std::iter::FromIterator;
use std::path::Path;
use std::process::Command;
static NAME: &'static str = "chroot";
static SYNTAX: &'static str = "[OPTION]... NEWROOT [COMMAND [ARG]...]";
static SUMMARY: &'static str = "Run COMMAND with root directory set to NEWROOT.";
static LONG_HELP: &'static str = "
static NAME: &str = "chroot";
static SYNTAX: &str = "[OPTION]... NEWROOT [COMMAND [ARG]...]";
static SUMMARY: &str = "Run COMMAND with root directory set to NEWROOT.";
static LONG_HELP: &str = "
If COMMAND is not specified, it defaults to '$(SHELL) -i'.
If $(SHELL) is not set, /bin/sh is used.
";
......@@ -140,7 +140,7 @@ fn enter_chroot(root: &Path) {
let root_str = root.display();
std::env::set_current_dir(root).unwrap();
let err = unsafe {
chroot(CString::new(".".as_bytes())
chroot(CString::new(".")
.unwrap()
.as_bytes_with_nul()
.as_ptr() as *const libc::c_char)
......
......@@ -8,7 +8,7 @@ name = "uu_cksum"
path = "cksum.rs"
[dependencies]
libc = "0.2.26"
libc = "0.2.42"
uucore = { path="../uucore" }
[[bin]]
......
......@@ -13,7 +13,7 @@ use std::fs::File;
use std::io::Write;
use std::path::Path;
static CRC_TABLE_LEN: usize = 256;
const CRC_TABLE_LEN: usize = 256;
#[path = "../../mkmain.rs"]
mod mkmain;
......
......@@ -20,9 +20,9 @@ use std::path::Path;
include!(concat!(env!("OUT_DIR"), "/crc_table.rs"));
static SYNTAX: &'static str = "[OPTIONS] [FILE]...";
static SUMMARY: &'static str = "Print CRC and size for each file";
static LONG_HELP: &'static str = "";
static SYNTAX: &str = "[OPTIONS] [FILE]...";
static SUMMARY: &str = "Print CRC and size for each file";
static LONG_HELP: &str = "";
#[inline]
fn crc_update(crc: u32, input: u8) -> u32 {
......
......@@ -9,8 +9,8 @@ name = "uu_comm"
path = "comm.rs"
[dependencies]
libc = "0.2.26"
getopts = "0.2.14"
libc = "0.2.42"
getopts = "0.2.18"
uucore = { path="../uucore" }
[[bin]]
......
......@@ -19,9 +19,9 @@ use std::fs::File;
use std::io::{self, stdin, BufRead, BufReader, Stdin};
use std::path::Path;
static SYNTAX: &'static str = "[OPTIONS] FILE1 FILE2";
static SUMMARY: &'static str = "Compare sorted files line by line";
static LONG_HELP: &'static str = "";
static SYNTAX: &str = "[OPTIONS] FILE1 FILE2";
static SUMMARY: &str = "Compare sorted files line by line";
static LONG_HELP: &str = "";
fn mkdelim(col: usize, opts: &getopts::Matches) -> String {
let mut s = String::new();
......
......@@ -12,12 +12,12 @@ name = "uu_cp"
path = "cp.rs"
[dependencies]
getopts = "0.2.14"
libc = "0.2.26"
walkdir = "1.0.7"
clap = "2.20.0"
quick-error = "1.1.0"
filetime = "0.1"