File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -197,12 +197,31 @@ llscan_mdns()
197197{
198198 local all=" $1 "
199199 local flags=" -tarp"
200+ local tmpfile i c pid
200201
201202 if avahi-browse --help 2>&1 | grep -q -- ' -k' ; then
202203 flags=" -tarpk"
203204 fi
204205
205- avahi-browse $flags 2> /dev/null | awk -F' ;' -v show_all=" $all " '
206+ tmpfile=$( mktemp)
207+ avahi-browse $flags 2> /dev/null > " $tmpfile " &
208+ pid=$!
209+
210+ if [ -t 2 ]; then
211+ i=0
212+ while kill -0 " $pid " 2> /dev/null; do
213+ case $(( i % 4 )) in
214+ 0) c=' -' ;; 1) c=" \\ " ;; 2) c=' |' ;; 3) c=' /' ;;
215+ esac
216+ printf " \r[%s] Scanning, please wait ..." " $c " >&2
217+ i=$(( i + 1 ))
218+ sleep 0.2
219+ done
220+ printf " \r\033[2K" >&2
221+ fi
222+
223+ wait " $pid "
224+ awk -F' ;' -v show_all=" $all " '
206225 $1 == "=" {
207226 host = $7
208227 proto = $3
@@ -279,7 +298,8 @@ llscan_mdns()
279298
280299 printf "\n%d device(s) found.\n", ndevs
281300 }
282- '
301+ ' " $tmpfile "
302+ rm -f " $tmpfile "
283303}
284304
285305llscan_ll ()
You can’t perform that action at this time.
0 commit comments