refactor(script): Reuse the same pkg name separator in a var (#1)
This commit is contained in:
		@@ -120,7 +120,7 @@ function write_pkg_list_oneline () {
 | 
			
		||||
    if [[ "${severity}" == 'imp' ]]; then
 | 
			
		||||
        for pkg in "${important_pkgs_in_transaction[@]}"; do
 | 
			
		||||
            if [[ "${unabridged_pkg_list_oneline}" ]]; then
 | 
			
		||||
                unabridged_pkg_list_oneline="${unabridged_pkg_list_oneline}"','"${pkg}"
 | 
			
		||||
                unabridged_pkg_list_oneline="${unabridged_pkg_list_oneline}${pkg_separator}${pkg}"
 | 
			
		||||
            else
 | 
			
		||||
                unabridged_pkg_list_oneline="${pkg}"
 | 
			
		||||
            fi
 | 
			
		||||
@@ -129,7 +129,7 @@ function write_pkg_list_oneline () {
 | 
			
		||||
    if [[ "${#trivial_pkgs_in_transaction[@]}" -ge '1' ]]; then
 | 
			
		||||
        for pkg in "${trivial_pkgs_in_transaction[@]}"; do
 | 
			
		||||
            if [[ "${unabridged_pkg_list_oneline}" ]]; then
 | 
			
		||||
                unabridged_pkg_list_oneline="${unabridged_pkg_list_oneline}"','"${pkg}"
 | 
			
		||||
                unabridged_pkg_list_oneline="${unabridged_pkg_list_oneline}${pkg_separator}${pkg}"
 | 
			
		||||
            else
 | 
			
		||||
                unabridged_pkg_list_oneline="${pkg}"
 | 
			
		||||
            fi
 | 
			
		||||
@@ -182,8 +182,8 @@ function trim_pkg_list_oneline () {
 | 
			
		||||
    local shorter_pkg_list
 | 
			
		||||
    shorter_pkg_list="${unabridged_pkg_list_oneline}"
 | 
			
		||||
    while [[ "${#shorter_pkg_list}" -gt "${pkgs_list_max_length}" ]]; do
 | 
			
		||||
        shorter_pkg_list="${shorter_pkg_list%,*}"
 | 
			
		||||
        if ! grep -Piq ',' <<<"${shorter_pkg_list}"; then
 | 
			
		||||
        shorter_pkg_list="${shorter_pkg_list%${pkg_separator}*}"
 | 
			
		||||
        if ! grep -Piq "${pkg_separator}" <<<"${shorter_pkg_list}"; then
 | 
			
		||||
            # Only one package remains in package list, no need to continue
 | 
			
		||||
            break
 | 
			
		||||
        fi
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user