| ... | ... |
@@ -1625,14 +1625,38 @@ function disable_all_services {
|
| 1625 | 1625 |
# Uses global ``ENABLED_SERVICES`` |
| 1626 | 1626 |
# disable_negated_services |
| 1627 | 1627 |
function disable_negated_services {
|
| 1628 |
- local tmpsvcs="${ENABLED_SERVICES}"
|
|
| 1628 |
+ local to_remove="" |
|
| 1629 |
+ local remaining="" |
|
| 1630 |
+ local enabled="" |
|
| 1629 | 1631 |
local service |
| 1630 |
- for service in ${tmpsvcs//,/ }; do
|
|
| 1632 |
+ |
|
| 1633 |
+ # build up list of services that should be removed; i.e. they |
|
| 1634 |
+ # begin with "-" |
|
| 1635 |
+ for service in ${ENABLED_SERVICES//,/ }; do
|
|
| 1631 | 1636 |
if [[ ${service} == -* ]]; then
|
| 1632 |
- tmpsvcs=$(echo ${tmpsvcs}|sed -r "s/(,)?(-)?${service#-}(,)?/,/g")
|
|
| 1637 |
+ to_remove+=",${service#-}"
|
|
| 1638 |
+ else |
|
| 1639 |
+ remaining+=",${service}"
|
|
| 1633 | 1640 |
fi |
| 1634 | 1641 |
done |
| 1635 |
- ENABLED_SERVICES=$(_cleanup_service_list "$tmpsvcs") |
|
| 1642 |
+ |
|
| 1643 |
+ # go through the service list. if this service appears in the "to |
|
| 1644 |
+ # be removed" list, drop it |
|
| 1645 |
+ for service in ${remaining//,/ }; do
|
|
| 1646 |
+ local remove |
|
| 1647 |
+ local add=1 |
|
| 1648 |
+ for remove in ${to_remove//,/ }; do
|
|
| 1649 |
+ if [[ ${remove} == ${service} ]]; then
|
|
| 1650 |
+ add=0 |
|
| 1651 |
+ break |
|
| 1652 |
+ fi |
|
| 1653 |
+ done |
|
| 1654 |
+ if [[ $add == 1 ]]; then |
|
| 1655 |
+ enabled="${enabled},$service"
|
|
| 1656 |
+ fi |
|
| 1657 |
+ done |
|
| 1658 |
+ |
|
| 1659 |
+ ENABLED_SERVICES=$(_cleanup_service_list "$enabled") |
|
| 1636 | 1660 |
} |
| 1637 | 1661 |
|
| 1638 | 1662 |
# disable_service() removes the services passed as argument to the |
| ... | ... |
@@ -127,7 +127,15 @@ test_disable_negated_services 'a,-a' '' |
| 127 | 127 |
test_disable_negated_services 'b,a,-a' 'b' |
| 128 | 128 |
test_disable_negated_services 'a,b,-a' 'b' |
| 129 | 129 |
test_disable_negated_services 'a,-a,b' 'b' |
| 130 |
- |
|
| 130 |
+test_disable_negated_services 'a,aa,-a' 'aa' |
|
| 131 |
+test_disable_negated_services 'aa,-a' 'aa' |
|
| 132 |
+test_disable_negated_services 'a_a, -a_a' '' |
|
| 133 |
+test_disable_negated_services 'a-b, -a-b' '' |
|
| 134 |
+test_disable_negated_services 'a-b, b, -a-b' 'b' |
|
| 135 |
+test_disable_negated_services 'a,-a,av2,b' 'av2,b' |
|
| 136 |
+test_disable_negated_services 'a,aa,-a' 'aa' |
|
| 137 |
+test_disable_negated_services 'a,av2,-a,a' 'av2' |
|
| 138 |
+test_disable_negated_services 'a,-a,av2' 'av2' |
|
| 131 | 139 |
|
| 132 | 140 |
echo "Testing is_package_installed()" |
| 133 | 141 |
|