mirror of
https://github.com/uutils/coreutils
synced 2024-11-15 01:17:09 +00:00
Merge pull request #1281 from rivy/alt/win-cli-globbing
Add command line globbing to all utilities (for windows targets)
This commit is contained in:
commit
5a17daa963
21 changed files with 157 additions and 97 deletions
116
.appveyor.yml
Normal file
116
.appveyor.yml
Normal file
|
@ -0,0 +1,116 @@
|
|||
version: "{build} ~ {branch}"
|
||||
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
|
||||
os: Visual Studio 2015
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- CHANNEL: nightly
|
||||
|
||||
environment:
|
||||
global:
|
||||
FEATURES: "generic"
|
||||
matrix:
|
||||
- CHANNEL: 1.27.0
|
||||
ARCH: i686
|
||||
TOOLCHAIN: msvc
|
||||
- CHANNEL: stable
|
||||
ARCH: i686
|
||||
TOOLCHAIN: msvc
|
||||
- CHANNEL: stable
|
||||
ARCH: x86_64
|
||||
TOOLCHAIN: msvc
|
||||
# - CHANNEL: beta
|
||||
# ARCH: i686
|
||||
# TOOLCHAIN: msvc
|
||||
# - CHANNEL: beta
|
||||
# ARCH: x86_64
|
||||
# TOOLCHAIN: msvc
|
||||
- CHANNEL: nightly
|
||||
ARCH: i686
|
||||
TOOLCHAIN: msvc
|
||||
- CHANNEL: nightly
|
||||
ARCH: x86_64
|
||||
TOOLCHAIN: msvc
|
||||
- CHANNEL: stable
|
||||
ARCH: i686
|
||||
TOOLCHAIN: gnu
|
||||
- CHANNEL: stable
|
||||
ARCH: x86_64
|
||||
TOOLCHAIN: gnu
|
||||
# - CHANNEL: beta
|
||||
# ARCH: i686
|
||||
# TOOLCHAIN: gnu
|
||||
# - CHANNEL: beta
|
||||
# ARCH: x86_64
|
||||
# TOOLCHAIN: gnu
|
||||
- CHANNEL: nightly
|
||||
ARCH: i686
|
||||
TOOLCHAIN: gnu
|
||||
- CHANNEL: nightly
|
||||
ARCH: x86_64
|
||||
TOOLCHAIN: gnu
|
||||
- CHANNEL: stable
|
||||
ARCH: i686
|
||||
TOOLCHAIN: 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
|
||||
|
||||
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%" & 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 }
|
||||
- set "TARGET=%ARCH%-pc-windows-%TOOLCHAIN%"
|
||||
# install `rust` via `rustup`
|
||||
- call 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
|
||||
- set "PATH=%PATH%;%USERPROFILE%\.cargo\bin"
|
||||
- rustc -vV
|
||||
- cargo -vV
|
||||
|
||||
# finalize FEATURES
|
||||
- if /I "%CHANNEL%"=="nightly" set "FEATURES=nightly %FEATURES%"
|
||||
|
||||
# "gnu" toolchain setup
|
||||
- if /I "%TOOLCHAIN%"=="gnu" set "PATH=%PATH%;C:\MinGW\bin"
|
||||
# * use the system MSYS if we can
|
||||
- if /I "%TOOLCHAIN%"=="gnu" if /I "%ARCH%"=="i686" set "MSYS_BITS=32"
|
||||
- if /I "%TOOLCHAIN%"=="gnu" if /I "%ARCH%"=="x86_64" set "MSYS_BITS=64"
|
||||
- if defined MSYS_BITS set PATH=C:\msys64\mingw%MSYS_BITS%\bin;C:\msys64\usr\bin;%PATH%
|
||||
# * specific MinGW, if specified
|
||||
- ps: |
|
||||
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};
|
||||
appveyor DownloadFile $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%
|
||||
|
||||
# "msvc" toolchain setup
|
||||
- if "%TOOLCHAIN%" == "msvc" if "%ARCH%" == "i686" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat"
|
||||
- if "%TOOLCHAIN%" == "msvc" if "%ARCH%" == "x86_64" "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
|
||||
- if "%TOOLCHAIN%" == "msvc" if "%ARCH%" == "x86_64" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
|
||||
|
||||
artifacts:
|
||||
- path: target\debug\uutils.exe
|
||||
name: uutils.exe
|
||||
|
||||
build_script:
|
||||
- cargo build --features "%FEATURES%" --no-default-features
|
||||
|
||||
test_script:
|
||||
- cargo test --no-fail-fast --features "%FEATURES%" --no-default-features
|
39
.travis.yml
39
.travis.yml
|
@ -1,19 +1,29 @@
|
|||
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:
|
||||
|
@ -38,20 +44,18 @@ 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; fi
|
||||
- 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
|
||||
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
|
||||
- mkdir installdir_test
|
||||
- DESTDIR=installdir_test make install
|
||||
- "[ `ls installdir_test/usr/local/bin | wc -l` -gt 0 ]"
|
||||
- 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:
|
||||
|
@ -64,4 +68,3 @@ after_success: |
|
|||
cargo tarpaulin --out Xml
|
||||
bash <(curl -s https://codecov.io/bash)
|
||||
fi
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ name = "uutils"
|
|||
version = "0.0.1"
|
||||
authors = []
|
||||
build = "build.rs"
|
||||
autotests = false
|
||||
|
||||
[features]
|
||||
unix = [
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
58
appveyor.yml
58
appveyor.yml
|
@ -1,58 +0,0 @@
|
|||
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
|
|
@ -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.
|
||||
|
|
|
@ -24,9 +24,6 @@ extern crate walkdir;
|
|||
#[cfg(unix)]
|
||||
extern crate xattr;
|
||||
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::io::AsRawHandle;
|
||||
|
||||
#[cfg(windows)]
|
||||
extern crate kernel32;
|
||||
#[cfg(windows)]
|
||||
|
@ -733,7 +730,7 @@ fn preserve_hardlinks(
|
|||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let mut stat = mem::uninitialized();
|
||||
let stat = mem::uninitialized();
|
||||
let handle = CreateFile2(
|
||||
src_path.as_ptr() as *const u16,
|
||||
winapi::um::winnt::GENERIC_READ,
|
||||
|
@ -748,7 +745,7 @@ fn preserve_hardlinks(
|
|||
std::io::Error::last_os_error()
|
||||
).into());
|
||||
}
|
||||
inode = (((*stat).nFileIndexHigh as u64) << 32 | (*stat).nFileIndexLow as u64);
|
||||
inode = ((*stat).nFileIndexHigh as u64) << 32 | (*stat).nFileIndexLow as u64;
|
||||
nlinks = (*stat).nNumberOfLinks as u64;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@ extern crate time;
|
|||
#[macro_use]
|
||||
extern crate uucore;
|
||||
|
||||
// XXX: remove when we no longer support 1.22.0
|
||||
use std::ascii::AsciiExt;
|
||||
use std::collections::HashSet;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
|
|
|
@ -32,8 +32,6 @@ use regex::Regex;
|
|||
use sha1::Sha1;
|
||||
use sha2::{Sha224, Sha256, Sha384, Sha512};
|
||||
use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512, Shake128, Shake256};
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::AsciiExt;
|
||||
use std::fs::File;
|
||||
use std::io::{self, stdin, BufRead, BufReader, Read};
|
||||
use std::path::Path;
|
||||
|
|
|
@ -18,6 +18,7 @@ use pretty_bytes::converter::convert;
|
|||
use term_grid::{Cell, Direction, Filling, Grid, GridOptions};
|
||||
use time::{strftime, Timespec};
|
||||
|
||||
#[cfg(unix)]
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
|
@ -587,11 +588,13 @@ fn color_name(name: String, typ: &str) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
macro_rules! has {
|
||||
($mode:expr, $perm:expr) => (
|
||||
$mode & ($perm as mode_t) != 0
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn display_file_name(
|
||||
path: &Path,
|
||||
|
@ -698,4 +701,3 @@ fn display_symlink_count(metadata: &Metadata) -> String {
|
|||
fn display_symlink_count(metadata: &Metadata) -> String {
|
||||
metadata.nlink().to_string()
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ extern crate libc;
|
|||
extern crate uucore;
|
||||
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
|
||||
static NAME: &str = "mkdir";
|
||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
|
|
@ -164,8 +164,6 @@ pub trait Capitalize {
|
|||
|
||||
impl Capitalize for str {
|
||||
fn capitalize(&self) -> String {
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::AsciiExt;
|
||||
self.char_indices()
|
||||
.fold(String::with_capacity(self.len()), |mut acc, x| {
|
||||
if x.0 != 0 {
|
||||
|
|
|
@ -14,8 +14,6 @@ extern crate getopts;
|
|||
#[macro_use]
|
||||
extern crate uucore;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::AsciiExt;
|
||||
use std::fs::{metadata, File, OpenOptions};
|
||||
use std::io::Result;
|
||||
use std::path::Path;
|
||||
|
|
|
@ -10,6 +10,7 @@ failure_derive = { version = "0.1.1", optional = true }
|
|||
time = { version = "0.1.40", optional = true }
|
||||
data-encoding = { version = "^2.1", optional = true }
|
||||
libc = { version = "0.2.42", optional = true }
|
||||
wild = "2.0.1"
|
||||
|
||||
[target.'cfg(target_os = "redox")'.dependencies]
|
||||
termion = "1.5"
|
||||
|
|
|
@ -25,6 +25,7 @@ use std::io::Result as IOResult;
|
|||
use std::path::{Component, Path, PathBuf};
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[cfg(unix)]
|
||||
macro_rules! has {
|
||||
($mode:expr, $perm:expr) => (
|
||||
$mode & ($perm as u32) != 0
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
extern crate wild;
|
||||
|
||||
pub fn args() -> impl Iterator<Item=String> {
|
||||
wild::args()
|
||||
}
|
||||
|
||||
#[cfg(feature = "libc")]
|
||||
pub extern crate libc;
|
||||
#[cfg(feature = "winapi")]
|
||||
|
|
|
@ -13,7 +13,6 @@ include!(concat!(env!("OUT_DIR"), "/uutils_crates.rs"));
|
|||
|
||||
use std::collections::hash_map::HashMap;
|
||||
use std::path::Path;
|
||||
use std::env;
|
||||
use std::io::Write;
|
||||
|
||||
extern crate uucore;
|
||||
|
@ -40,7 +39,7 @@ fn main() {
|
|||
uucore::panic::install_sigpipe_hook();
|
||||
|
||||
let umap = util_map();
|
||||
let mut args: Vec<String> = env::args().collect();
|
||||
let mut args: Vec<String> = uucore::args().collect();
|
||||
|
||||
// try binary name as util name.
|
||||
let args0 = args[0].clone();
|
||||
|
|
|
@ -16,8 +16,6 @@ extern crate uucore;
|
|||
|
||||
use getopts::{Matches, Options};
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use std::ascii::AsciiExt;
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, BufRead, BufReader, Read};
|
||||
use std::path::Path;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use common::util::*;
|
||||
#[cfg(not(windows))]
|
||||
use std::fs::set_permissions;
|
||||
|
||||
static TEST_EXISTING_FILE: &str = "existing_file.txt";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#[macro_use]
|
||||
mod common;
|
||||
|
||||
#[cfg(unix)]
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
|
|
Loading…
Reference in a new issue