Skip to content

Commit

Permalink
file-size-fix: ability to restrict fix to resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Edgin committed Sep 26, 2023
1 parent 0a81c3b commit dc47fa7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions fix-file-size
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Options:
-h, --help show help and exit
-J, --jobs NUM-JOBS the number of fixes to perform simultaneously
-R, --resc RESC only fix replicas on resource RESC
-v, --version show version and exit
Summary:
Expand All @@ -32,10 +33,13 @@ set -o errexit -o nounset -o pipefail

ExecPath="$(readlink --canonicalize "$0")"
ExecName="$(basename "$ExecPath")"
readonnly ExecName ExecPath
readonly ExecName ExecPath

export RESC

main() {
if ! opts="$(getopt --name "$ExecName" --options hJ:v --longoptions help,jobs:,version -- "$@")"
local opts
if ! opts="$(format_opts "$@")"
then
printf '\n' >&2
show_help >&2
Expand All @@ -56,6 +60,10 @@ main() {
jobs="$2"
shift 2
;;
-R|--resc)
RESC="$2"
shift 2
;;
-v|--version)
show_version
exit 0
Expand Down Expand Up @@ -84,12 +92,17 @@ main() {
parallel --eta --no-notice --delimiter '\n' --max-args 1 "$JobsOpt" FIX > /dev/null
}

format_opts() {
getopt --name "$ExecName" --options hJ:R:v --longoptions help,jobs:,resc:,version -- "$@"
}

show_version() {
printf '%s\n' "$Version"
}

FIX() {
local objPath="$1"
#printf '"%s"\n' "$RESC" >&2

set -o errexit -o nounset -o pipefail

Expand Down Expand Up @@ -144,7 +157,7 @@ CMD
fi

fixed="$objPath"
done < <("$EXEC_DIR"/get-replicas "$objPath") >&2
done < <("$EXEC_DIR"/get-replicas --resc="${RESC-}" "$objPath") >&2

if [[ -z "${fixed-}" ]]
then
Expand Down

0 comments on commit dc47fa7

Please sign in to comment.