| 
									
										
										
										
											2021-01-08 18:04:51 +08:00
										 |  |  | homebrew-items() { | 
					
						
							|  |  |  |   local items | 
					
						
							|  |  |  |   local sed_extended_regex_flag | 
					
						
							| 
									
										
										
										
											2023-05-22 18:20:18 -07:00
										 |  |  |   local find_args | 
					
						
							| 
									
										
										
										
											2022-11-20 16:22:18 -05:00
										 |  |  |   local find_include_filter="$1" | 
					
						
							|  |  |  |   local find_exclude_filter="$2" | 
					
						
							|  |  |  |   local sed_filter="$3" | 
					
						
							|  |  |  |   local grep_filter="$4" | 
					
						
							| 
									
										
										
										
											2021-01-08 18:04:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-17 20:56:56 +09:00
										 |  |  |   # HOMEBREW_MACOS is set by brew.sh | 
					
						
							|  |  |  |   # shellcheck disable=SC2154 | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |   if [[ -n "${HOMEBREW_MACOS}" ]] | 
					
						
							|  |  |  |   then | 
					
						
							| 
									
										
										
										
											2021-01-08 18:04:51 +08:00
										 |  |  |     sed_extended_regex_flag="-E" | 
					
						
							| 
									
										
										
										
											2023-05-22 18:20:18 -07:00
										 |  |  |     find_args=("-E" "${HOMEBREW_REPOSITORY}/Library/Taps") | 
					
						
							| 
									
										
										
										
											2021-01-08 18:04:51 +08:00
										 |  |  |   else | 
					
						
							|  |  |  |     sed_extended_regex_flag="-r" | 
					
						
							| 
									
										
										
										
											2023-05-22 18:20:18 -07:00
										 |  |  |     find_args=("${HOMEBREW_REPOSITORY}/Library/Taps" "-regextype" "posix-extended") | 
					
						
							| 
									
										
										
										
											2021-01-08 18:04:51 +08:00
										 |  |  |   fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-17 20:56:56 +09:00
										 |  |  |   # HOMEBREW_REPOSITORY is set by brew.sh | 
					
						
							|  |  |  |   # shellcheck disable=SC2154 | 
					
						
							| 
									
										
										
										
											2022-12-16 13:37:15 -08:00
										 |  |  |   [[ -d "${HOMEBREW_REPOSITORY}/Library/Taps" ]] || return | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |   items="$( | 
					
						
							| 
									
										
										
										
											2023-05-22 18:20:18 -07:00
										 |  |  |     find "${find_args[@]}" \
 | 
					
						
							| 
									
										
										
										
											2021-09-16 01:08:02 +08:00
										 |  |  |       -type d \( \
 | 
					
						
							| 
									
										
										
										
											2023-05-22 18:20:18 -07:00
										 |  |  |       -regex "${find_exclude_filter}" -o \
 | 
					
						
							| 
									
										
										
										
											2021-09-16 01:08:02 +08:00
										 |  |  |       -name cmd -o \
 | 
					
						
							|  |  |  |       -name .github -o \
 | 
					
						
							|  |  |  |       -name lib -o \
 | 
					
						
							|  |  |  |       -name spec -o \
 | 
					
						
							| 
									
										
										
										
											2024-08-10 06:09:22 -06:00
										 |  |  |       -name vendor -o \
 | 
					
						
							|  |  |  |       -name .git \
 | 
					
						
							| 
									
										
										
										
											2021-09-16 01:08:02 +08:00
										 |  |  |       \) \
 | 
					
						
							| 
									
										
										
										
											2022-11-20 16:22:18 -05:00
										 |  |  |       -prune -false -o -path "${find_include_filter}" | | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |       sed "${sed_extended_regex_flag}" \
 | 
					
						
							| 
									
										
										
										
											2021-09-16 01:08:02 +08:00
										 |  |  |         -e 's/\.rb//g' \
 | 
					
						
							|  |  |  |         -e 's_.*/Taps/(.*)/(home|linux)brew-_\1/_' \
 | 
					
						
							|  |  |  |         -e "${sed_filter}" | 
					
						
							| 
									
										
										
										
											2021-01-08 18:04:51 +08:00
										 |  |  |   )"
 | 
					
						
							|  |  |  |   local shortnames | 
					
						
							| 
									
										
										
										
											2021-04-17 20:56:56 +09:00
										 |  |  |   shortnames="$(echo "${items}" | cut -d "/" -f 3)" | 
					
						
							| 
									
										
										
										
											2021-09-13 20:32:20 +08:00
										 |  |  |   echo -e "${items}\n${shortnames}" | | 
					
						
							|  |  |  |     grep -v "${grep_filter}" | | 
					
						
							| 
									
										
										
										
											2021-01-08 18:04:51 +08:00
										 |  |  |     sort -uf | 
					
						
							|  |  |  | } |