File tree Expand file tree Collapse file tree 1 file changed +9
-16
lines changed
Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Original file line number Diff line number Diff line change 22# Synchronize Drupal extensions (modules and themes) to match core.extension.yml.
33echo " Sync Extensions : Synchronizing modules and themes..."
44
5- # Gets items in list1 but not in list2 (space-separated)
5+ # Gets items in list1 but not in list2 (space-separated) - O(n log n)
66diff_lists () {
77 LIST1=" $1 "
88 LIST2=" $2 "
9- RESULT=" "
10- for item in $LIST1 ; do
11- [ -z " $item " ] && continue
12- FOUND=0
13- for check in $LIST2 ; do
14- if [ " $item " = " $check " ]; then
15- FOUND=1
16- break
17- fi
18- done
19- if [ " $FOUND " -eq 0 ]; then
20- RESULT=" $RESULT $item "
21- fi
22- done
23- echo " $RESULT " | xargs
9+ # Handle empty lists
10+ [ -z " $LIST1 " ] && return
11+ [ -z " $LIST2 " ] && { echo " $LIST1 " | xargs; return ; }
12+ # Use comm for efficient set difference (requires sorted input)
13+ printf ' %s\n' $LIST1 | sort > /tmp/diff_list1.$$
14+ printf ' %s\n' $LIST2 | sort > /tmp/diff_list2.$$
15+ comm -23 /tmp/diff_list1.$$ /tmp/diff_list2.$$ | tr ' \n' ' ' | xargs
16+ rm -f /tmp/diff_list1.$$ /tmp/diff_list2.$$
2417}
2518
2619# Gets if item exists in list
You can’t perform that action at this time.
0 commit comments