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
|
||||
|
||||
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.
|
||||
|
|
|
|||
26
dockcheck.sh
26
dockcheck.sh
|
|
@ -229,7 +229,7 @@ self_update() {
|
|||
|
||||
choosecontainers() {
|
||||
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
|
||||
[[ -n "${BackupForDays:-}" ]] && remove_backups
|
||||
exit 0
|
||||
|
|
@ -238,12 +238,28 @@ choosecontainers() {
|
|||
ChoiceClean=${Choice//[,.:;]/ }
|
||||
else
|
||||
ChoiceClean=${Choice//[,.:;]/ }
|
||||
SelectedUpdates=()
|
||||
for CC in $ChoiceClean; do
|
||||
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
|
||||
if [[ "$CC" == *-* ]]; then
|
||||
if [[ "$CC" =~ ^([0-9]+)-([0-9]+)$ ]]; then
|
||||
# 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
|
||||
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
|
||||
done
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue