diff options
author | Ismael Luceno | 2016-08-10 18:24:57 -0300 |
---|---|---|
committer | Ismael Luceno | 2016-08-13 19:49:11 -0300 |
commit | 48cefbc49f33e84889502f8bfdeb0cbfea3dce02 (patch) | |
tree | f302e53590e92545d81aa07d38cab3bd4100c465 | |
parent | 8a4f61425c5216f2beac2ac5860e79d10404c4e0 (diff) |
libupdate: Improve multiversion_check suggestions
More comprehensive collection with de-duplication in a single command
invocation. Also, suppresses spell description.
-rw-r--r-- | var/lib/quill/modules/libupdate | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/var/lib/quill/modules/libupdate b/var/lib/quill/modules/libupdate index 9dc8944..db8dfe7 100644 --- a/var/lib/quill/modules/libupdate +++ b/var/lib/quill/modules/libupdate @@ -116,16 +116,30 @@ function count_spaces() #--- function multiversion_check() { - local suggestions if [[ ${#versions[@]} != 1 ]] then #we have a problem message "Oh dear, detected a multiversion spell. Going to cat DETAILS for you " message "and then you will tell me which variable I need to set, so I can get " message "to the correct version ($version)." sleep 3 - cat DETAILS - suggestions=$(sed -n 's,[{}],,g; s,^.*if.*$\([A-Za-z_]*\).*$,\1,p' DETAILS) - [[ ! -z $suggestions ]] && query_msg "Perhaps it is one of these:" $suggestions + # suggestions + awk ' + /^[\t ]*cat/ { exit } # Suppress description + { print } + function take(s) { gsub(/["${}]+/, "", s); S[s] } + /^[\t ]*case/ { + take($2) + while (getline == 1 && !/^[\t ]*esac/) + print + next + } + /^[\t ]*(el)?if +\[\[? +[^-]/ { take($3) } + END { + if (!length(S)) exit + for (i in S) s = s " " i + print "\nPerhaps it is one of these:" s + } + ' DETAILS query_string version_switch "${QUERY_COLOR}Please enter the appropriate variable. Example: UGU_DEVEL=y${DEFAULT_COLOR} " fi } |