mirror of
https://github.com/uutils/coreutils
synced 2024-12-12 14:22:41 +00:00
update shell scripts according to shellcheck recommendations and minor cleanup
This commit is contained in:
parent
dfc661e8b5
commit
d762bebc1c
9 changed files with 52 additions and 56 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
rustup target add x86_64-unknown-redox
|
rustup target add x86_64-unknown-redox
|
||||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA12E97F0881517F
|
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA12E97F0881517F
|
||||||
|
|
|
@ -15,21 +15,21 @@ ME_parent_dir_abs="$(realpath -mP -- "${ME_parent_dir}")"
|
||||||
|
|
||||||
# * `gh` available?
|
# * `gh` available?
|
||||||
unset GH
|
unset GH
|
||||||
gh --version 1>/dev/null 2>&1
|
if gh --version 1>/dev/null 2>&1; then
|
||||||
if [ $? -eq 0 ]; then export GH="gh"; fi
|
export GH="gh"
|
||||||
|
else
|
||||||
|
echo "ERR!: missing \`gh\` (see install instructions at <https://github.com/cli/cli>)" 1>&2
|
||||||
|
fi
|
||||||
|
|
||||||
# * `jq` available?
|
# * `jq` available?
|
||||||
unset JQ
|
unset JQ
|
||||||
jq --version 1>/dev/null 2>&1
|
if jq --version 1>/dev/null 2>&1; then
|
||||||
if [ $? -eq 0 ]; then export JQ="jq"; fi
|
export JQ="jq"
|
||||||
|
else
|
||||||
|
echo "ERR!: missing \`jq\` (install with \`sudo apt install jq\`)" 1>&2
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${GH}" ] || [ -z "${JQ}" ]; then
|
if [ -z "${GH}" ] || [ -z "${JQ}" ]; then
|
||||||
if [ -z "${GH}" ]; then
|
|
||||||
echo 'ERR!: missing `gh` (see install instructions at <https://github.com/cli/cli>)' 1>&2
|
|
||||||
fi
|
|
||||||
if [ -z "${JQ}" ]; then
|
|
||||||
echo 'ERR!: missing `jq` (install with `sudo apt install jq`)' 1>&2
|
|
||||||
fi
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
|
|
||||||
FEATURES_OPTION="--features feat_os_unix"
|
FEATURES_OPTION="--features feat_os_unix"
|
||||||
|
|
||||||
ME_dir="$(dirname -- $(readlink -fm -- "$0"))"
|
ME_dir="$(dirname -- "$(readlink -fm -- "$0")")"
|
||||||
REPO_main_dir="$(dirname -- "${ME_dir}")"
|
REPO_main_dir="$(dirname -- "${ME_dir}")"
|
||||||
|
|
||||||
cd "${REPO_main_dir}"
|
cd "${REPO_main_dir}" &&
|
||||||
echo "[ \"$PWD\" ]"
|
echo "[ \"$PWD\" ]"
|
||||||
|
|
||||||
|
#shellcheck disable=SC2086
|
||||||
UTIL_LIST=$("${ME_dir}"/show-utils.sh ${FEATURES_OPTION})
|
UTIL_LIST=$("${ME_dir}"/show-utils.sh ${FEATURES_OPTION})
|
||||||
CARGO_INDIVIDUAL_PACKAGE_OPTIONS=""
|
CARGO_INDIVIDUAL_PACKAGE_OPTIONS=""
|
||||||
for UTIL in ${UTIL_LIST}; do
|
for UTIL in ${UTIL_LIST}; do
|
||||||
|
@ -30,10 +31,12 @@ export RUSTC_WRAPPER="" ## NOTE: RUSTC_WRAPPER=='sccache' breaks code covera
|
||||||
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
|
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
|
||||||
export RUSTDOCFLAGS="-Cpanic=abort"
|
export RUSTDOCFLAGS="-Cpanic=abort"
|
||||||
export RUSTUP_TOOLCHAIN="nightly-gnu"
|
export RUSTUP_TOOLCHAIN="nightly-gnu"
|
||||||
cargo build ${FEATURES_OPTION}
|
#shellcheck disable=SC2086
|
||||||
cargo test --no-run ${FEATURES_OPTION}
|
{ cargo build ${FEATURES_OPTION}
|
||||||
cargo test --quiet ${FEATURES_OPTION}
|
cargo test --no-run ${FEATURES_OPTION}
|
||||||
cargo test --quiet ${FEATURES_OPTION} ${CARGO_INDIVIDUAL_PACKAGE_OPTIONS}
|
cargo test --quiet ${FEATURES_OPTION}
|
||||||
|
cargo test --quiet ${FEATURES_OPTION} ${CARGO_INDIVIDUAL_PACKAGE_OPTIONS}
|
||||||
|
}
|
||||||
|
|
||||||
export COVERAGE_REPORT_DIR
|
export COVERAGE_REPORT_DIR
|
||||||
if [ -z "${COVERAGE_REPORT_DIR}" ]; then COVERAGE_REPORT_DIR="${REPO_main_dir}/target/debug/coverage-nix"; fi
|
if [ -z "${COVERAGE_REPORT_DIR}" ]; then COVERAGE_REPORT_DIR="${REPO_main_dir}/target/debug/coverage-nix"; fi
|
||||||
|
@ -47,8 +50,7 @@ mkdir -p "${COVERAGE_REPORT_DIR}"
|
||||||
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_DIR}/../lcov.info" --branch --ignore build.rs --ignore '/*' --ignore '[A-Za-z]:/*' --ignore 'C:/Users/*' --excl-br-line '^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()'
|
grcov . --output-type lcov --output-path "${COVERAGE_REPORT_DIR}/../lcov.info" --branch --ignore build.rs --ignore '/*' --ignore '[A-Za-z]:/*' --ignore 'C:/Users/*' --excl-br-line '^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()'
|
||||||
# * build HTML
|
# * build HTML
|
||||||
# -- use `genhtml` if available for display of additional branch coverage information
|
# -- use `genhtml` if available for display of additional branch coverage information
|
||||||
genhtml --version 2>/dev/null 1>&2
|
if genhtml --version 2>/dev/null 1>&2; then
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
genhtml "${COVERAGE_REPORT_DIR}/../lcov.info" --output-directory "${COVERAGE_REPORT_DIR}" --branch-coverage --function-coverage | grep ": [0-9]"
|
genhtml "${COVERAGE_REPORT_DIR}/../lcov.info" --output-directory "${COVERAGE_REPORT_DIR}" --branch-coverage --function-coverage | grep ": [0-9]"
|
||||||
else
|
else
|
||||||
grcov . --output-type html --output-path "${COVERAGE_REPORT_DIR}" --branch --ignore build.rs --ignore '/*' --ignore '[A-Za-z]:/*' --ignore 'C:/Users/*' --excl-br-line '^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()'
|
grcov . --output-type html --output-path "${COVERAGE_REPORT_DIR}" --branch --ignore build.rs --ignore '/*' --ignore '[A-Za-z]:/*' --ignore 'C:/Users/*' --excl-br-line '^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()'
|
||||||
|
|
|
@ -15,7 +15,7 @@ if test ! -d ../gnulib; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
pushd $(pwd)
|
pushd "$PWD"
|
||||||
make PROFILE=release
|
make PROFILE=release
|
||||||
BUILDDIR="$PWD/target/release/"
|
BUILDDIR="$PWD/target/release/"
|
||||||
cp "${BUILDDIR}/install" "${BUILDDIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target
|
cp "${BUILDDIR}/install" "${BUILDDIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target
|
||||||
|
@ -49,7 +49,7 @@ make -j "$(nproc)"
|
||||||
# Used to be 36. Reduced to 20 to decrease the log size
|
# Used to be 36. Reduced to 20 to decrease the log size
|
||||||
for i in {00..20}
|
for i in {00..20}
|
||||||
do
|
do
|
||||||
make tests/factor/t${i}.sh
|
make "tests/factor/t${i}.sh"
|
||||||
done
|
done
|
||||||
|
|
||||||
# strip the long stuff
|
# strip the long stuff
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
ARG=""
|
ARG=""
|
||||||
|
@ -6,26 +6,21 @@ if test "$1" != "--do-it"; then
|
||||||
ARG="--dry-run --allow-dirty"
|
ARG="--dry-run --allow-dirty"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd src/uucore/
|
for dir in src/uucore/ src/uucore_procs/ src/uu/stdbuf/src/libstdbuf/ ; do
|
||||||
cargo publish $ARG
|
( cd "$dir"
|
||||||
cd -
|
#shellcheck disable=SC2086
|
||||||
sleep 2s
|
cargo publish $ARG
|
||||||
|
)
|
||||||
cd src/uucore_procs/
|
sleep 2s
|
||||||
cargo publish $ARG
|
done
|
||||||
cd -
|
|
||||||
sleep 2s
|
|
||||||
|
|
||||||
cd src/uu/stdbuf/src/libstdbuf/
|
|
||||||
cargo publish $ARG
|
|
||||||
cd -
|
|
||||||
sleep 2s
|
|
||||||
|
|
||||||
PROGS=$(ls -1d src/uu/*/)
|
PROGS=$(ls -1d src/uu/*/)
|
||||||
for p in $PROGS; do
|
for p in $PROGS; do
|
||||||
cd $p
|
( cd "$p"
|
||||||
cargo publish $ARG
|
#shellcheck disable=SC2086
|
||||||
cd -
|
cargo publish $ARG
|
||||||
|
)
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#shellcheck disable=SC2086
|
||||||
cargo publish $ARG
|
cargo publish $ARG
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# spell-checker:ignore (env/vars) BUILDDIR GNULIB SUBDIRS
|
# spell-checker:ignore (env/vars) BUILDDIR GNULIB SUBDIRS
|
||||||
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
cd "$(dirname -- "$(readlink -fm -- "$0")")/../.."
|
||||||
set -e
|
set -e
|
||||||
BUILDDIR="${PWD}/uutils/target/release"
|
BUILDDIR="${PWD}/uutils/target/release"
|
||||||
GNULIB_DIR="${PWD}/gnulib"
|
GNULIB_DIR="${PWD}/gnulib"
|
||||||
|
@ -13,4 +13,5 @@ if test -n "$1"; then
|
||||||
export RUN_TEST="TESTS=$1"
|
export RUN_TEST="TESTS=$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#shellcheck disable=SC2086
|
||||||
timeout -sKILL 2h make -j "$(nproc)" check $RUN_TEST SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no || : # Kill after 4 hours in case something gets stuck in make
|
timeout -sKILL 2h make -j "$(nproc)" check $RUN_TEST SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no || : # Kill after 4 hours in case something gets stuck in make
|
||||||
|
|
|
@ -2,15 +2,14 @@
|
||||||
|
|
||||||
# spell-checker:ignore (vars) OSID
|
# spell-checker:ignore (vars) OSID
|
||||||
|
|
||||||
ME_dir="$(dirname -- $(readlink -fm -- "$0"))"
|
ME_dir="$(dirname -- "$(readlink -fm -- "$0")")"
|
||||||
REPO_main_dir="$(dirname -- "${ME_dir}")"
|
REPO_main_dir="$(dirname -- "${ME_dir}")"
|
||||||
|
|
||||||
export COVERAGE_REPORT_DIR="${REPO_main_dir}/target/debug/coverage-nix"
|
export COVERAGE_REPORT_DIR="${REPO_main_dir}/target/debug/coverage-nix"
|
||||||
|
|
||||||
"${ME_dir}/build-code_coverage.sh"
|
if ! "${ME_dir}/build-code_coverage.sh"; then exit 1 ; fi
|
||||||
if [ $? -ne 0 ]; then exit 1 ; fi
|
|
||||||
|
|
||||||
case ";$OSID_tags;" in
|
case ";$OSID_tags;" in
|
||||||
*";wsl;"* ) powershell.exe -c $(wslpath -w "${COVERAGE_REPORT_DIR}"/index.html) ;;
|
*";wsl;"* ) powershell.exe -c "$(wslpath -w "${COVERAGE_REPORT_DIR}"/index.html)" ;;
|
||||||
* ) xdg-open --version >/dev/null 2>&1 && xdg-open "${COVERAGE_REPORT_DIR}"/index.html || echo "report available at '\"${COVERAGE_REPORT_DIR}\"/index.html'" ;;
|
* ) xdg-open --version >/dev/null 2>&1 && xdg-open "${COVERAGE_REPORT_DIR}"/index.html || echo "report available at '\"${COVERAGE_REPORT_DIR}\"/index.html'" ;;
|
||||||
esac ;
|
esac ;
|
||||||
|
|
|
@ -15,17 +15,13 @@ default_utils="base32 base64 basename cat cksum comm cp cut date dircolors dirna
|
||||||
|
|
||||||
project_main_dir="${ME_parent_dir_abs}"
|
project_main_dir="${ME_parent_dir_abs}"
|
||||||
# printf 'project_main_dir="%s"\n' "${project_main_dir}"
|
# printf 'project_main_dir="%s"\n' "${project_main_dir}"
|
||||||
cd "${project_main_dir}"
|
cd "${project_main_dir}" &&
|
||||||
|
|
||||||
# `jq` available?
|
# `jq` available?
|
||||||
unset JQ
|
if ! jq --version 1>/dev/null 2>&1; then
|
||||||
jq --version 1>/dev/null 2>&1
|
echo "WARN: missing \`jq\` (install with \`sudo apt install jq\`); falling back to default (only fully cross-platform) utility list" 1>&2
|
||||||
if [ $? -eq 0 ]; then export JQ="jq"; fi
|
echo "$default_utils"
|
||||||
|
|
||||||
if [ -z "${JQ}" ]; then
|
|
||||||
echo 'WARN: missing `jq` (install with `sudo apt install jq`); falling back to default (only fully cross-platform) utility list' 1>&2
|
|
||||||
echo $default_utils
|
|
||||||
else
|
else
|
||||||
cargo metadata $* --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string | sub(\"^uu_\"; \"\")] | sort | join(\" \")"
|
cargo metadata "$*" --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string | sub(\"^uu_\"; \"\")] | sort | join(\" \")"
|
||||||
# cargo metadata $* --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string] | sort | join(\" \")"
|
# cargo metadata "$*" --format-version 1 | jq -r "[.resolve.nodes[] | { id: .id, deps: [.deps[] | { name:.name, pkg:.pkg }] }] | .[] | select(.id|startswith(\"coreutils\")) | [.deps[] | select((.name|startswith(\"uu_\")) or (.pkg|startswith(\"uu_\")))] | [.[].pkg | match(\"^\\\w+\";\"g\")] | [.[].string] | sort | join(\" \")"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# This is a stupid helper. I will mass replace all versions (including other crates)
|
# This is a stupid helper. I will mass replace all versions (including other crates)
|
||||||
# So, it should be triple-checked
|
# So, it should be triple-checked
|
||||||
|
|
||||||
# How to ship a new release:
|
# How to ship a new release:
|
||||||
# 1) update this script
|
# 1) update this script
|
||||||
# 2) run it: bash util/update-version.sh
|
# 2) run it: sh util/update-version.sh
|
||||||
# 3) Do a spot check with "git diff"
|
# 3) Do a spot check with "git diff"
|
||||||
# 4) cargo test --release --features unix
|
# 4) cargo test --release --features unix
|
||||||
# 5) Run util/publish.sh in dry mode (it will fail as packages needs more recent version of uucore)
|
# 5) Run util/publish.sh in dry mode (it will fail as packages needs more recent version of uucore)
|
||||||
|
@ -23,6 +23,7 @@ UUCORE_TO="0.0.11"
|
||||||
PROGS=$(ls -1d src/uu/*/Cargo.toml src/uu/stdbuf/src/libstdbuf/Cargo.toml Cargo.toml src/uu/base64/Cargo.toml)
|
PROGS=$(ls -1d src/uu/*/Cargo.toml src/uu/stdbuf/src/libstdbuf/Cargo.toml Cargo.toml src/uu/base64/Cargo.toml)
|
||||||
|
|
||||||
# update the version of all programs
|
# update the version of all programs
|
||||||
|
#shellcheck disable=SC2086
|
||||||
sed -i -e "s|version = \"$FROM\"|version = \"$TO\"|" $PROGS
|
sed -i -e "s|version = \"$FROM\"|version = \"$TO\"|" $PROGS
|
||||||
|
|
||||||
# Update uucore_procs
|
# Update uucore_procs
|
||||||
|
@ -35,6 +36,8 @@ sed -i -e "s|= { optional=true, version=\"$FROM\", package=\"uu_|= { optional=tr
|
||||||
# Update uucore itself
|
# Update uucore itself
|
||||||
sed -i -e "s|version = \"$UUCORE_FROM\"|version = \"$UUCORE_TO\"|" src/uucore/Cargo.toml
|
sed -i -e "s|version = \"$UUCORE_FROM\"|version = \"$UUCORE_TO\"|" src/uucore/Cargo.toml
|
||||||
# Update crates using uucore
|
# Update crates using uucore
|
||||||
|
#shellcheck disable=SC2086
|
||||||
sed -i -e "s|uucore = { version=\">=$UUCORE_FROM\",|uucore = { version=\">=$UUCORE_TO\",|" $PROGS
|
sed -i -e "s|uucore = { version=\">=$UUCORE_FROM\",|uucore = { version=\">=$UUCORE_TO\",|" $PROGS
|
||||||
# Update crates using uucore_procs
|
# Update crates using uucore_procs
|
||||||
|
#shellcheck disable=SC2086
|
||||||
sed -i -e "s|uucore_procs = { version=\">=$UUCORE_PROCS_FROM\",|uucore_procs = { version=\">=$UUCORE_PROCS_TO\",|" $PROGS
|
sed -i -e "s|uucore_procs = { version=\">=$UUCORE_PROCS_FROM\",|uucore_procs = { version=\">=$UUCORE_PROCS_TO\",|" $PROGS
|
||||||
|
|
Loading…
Reference in a new issue