mirror of
https://github.com/mag37/dockcheck.git
synced 2026-03-02 07:00:34 +01:00
Allow ranges to be used for selection (#267)
* Allow ranges to be used for selection. * String consistency * Yet another change of the selection dialog, as suggested. --------- Co-authored-by: Max <>
This commit is contained in:
parent
7785e869d3
commit
5cef6c20ff
2 changed files with 22 additions and 6 deletions
|
|
@ -99,7 +99,7 @@ Containers with updates available:
|
||||||
03) whoogle-search
|
03) whoogle-search
|
||||||
|
|
||||||
Choose what containers to update:
|
Choose what containers to update:
|
||||||
Enter number(s) separated by comma, [a] for all - [q] to quit: 1,2
|
Enter number(s) or range(s) separated by comma (e.g. 1-2,4-5,09), [a] for all - [q] to quit: 1-2
|
||||||
```
|
```
|
||||||
|
|
||||||
Then it proceeds to run `pull` and `up -d` on every container with updates.
|
Then it proceeds to run `pull` and `up -d` on every container with updates.
|
||||||
|
|
|
||||||
26
dockcheck.sh
26
dockcheck.sh
|
|
@ -229,7 +229,7 @@ self_update() {
|
||||||
|
|
||||||
choosecontainers() {
|
choosecontainers() {
|
||||||
while [[ -z "${ChoiceClean:-}" ]]; do
|
while [[ -z "${ChoiceClean:-}" ]]; do
|
||||||
read -r -p "Enter number(s) separated by comma, [a] for all - [q] to quit: " Choice
|
read -r -p "Enter number(s) or range(s) separated by comma (e.g. 1-2,4-5,09), [a] for all - [q] to quit: " Choice
|
||||||
if [[ "$Choice" =~ [qQnN] ]]; then
|
if [[ "$Choice" =~ [qQnN] ]]; then
|
||||||
[[ -n "${BackupForDays:-}" ]] && remove_backups
|
[[ -n "${BackupForDays:-}" ]] && remove_backups
|
||||||
exit 0
|
exit 0
|
||||||
|
|
@ -238,12 +238,28 @@ choosecontainers() {
|
||||||
ChoiceClean=${Choice//[,.:;]/ }
|
ChoiceClean=${Choice//[,.:;]/ }
|
||||||
else
|
else
|
||||||
ChoiceClean=${Choice//[,.:;]/ }
|
ChoiceClean=${Choice//[,.:;]/ }
|
||||||
|
SelectedUpdates=()
|
||||||
for CC in $ChoiceClean; do
|
for CC in $ChoiceClean; do
|
||||||
CC=$((10#$CC)) # Base 10 interpretation to strip leading zeroes
|
if [[ "$CC" == *-* ]]; then
|
||||||
if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]]; then # Reset choice if out of bounds
|
if [[ "$CC" =~ ^([0-9]+)-([0-9]+)$ ]]; then
|
||||||
echo "Number not in list: $CC"; unset ChoiceClean; break 1
|
# Enforce base 10 to avoid octal parsing of leading zeroes
|
||||||
|
RangeStart=$((10#${BASH_REMATCH[1]}))
|
||||||
|
RangeEnd=$((10#${BASH_REMATCH[2]}))
|
||||||
|
if [[ "$RangeStart" -lt 1 || "$RangeEnd" -gt $UpdCount || "$RangeStart" -gt "$RangeEnd" ]]; then
|
||||||
|
echo "Entered list is out of bounds: $CC"; unset ChoiceClean; break 1
|
||||||
|
else
|
||||||
|
for ((idx=RangeStart; idx<=RangeEnd; idx++)); do SelectedUpdates+=( "${GotUpdates[$idx-1]}" ); done
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Invalid range: $CC"; unset ChoiceClean; break 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
SelectedUpdates+=( "${GotUpdates[$CC-1]}" )
|
CC=$((10#$CC)) # Base 10 interpretation to strip leading zeroes
|
||||||
|
if [[ "$CC" -lt 1 || "$CC" -gt $UpdCount ]]; then # Reset choice if out of bounds
|
||||||
|
echo "Number not in list: $CC"; unset ChoiceClean; break 1
|
||||||
|
else
|
||||||
|
SelectedUpdates+=( "${GotUpdates[$CC-1]}" )
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue