TOOLS/mpv_identify.sh: simplify line-by-line reading

Use here-document idiom to read mpv output line-by-line.
This commit is contained in:
shdown 2014-09-16 20:23:04 +04:00 committed by wm4
parent 6ef40cb910
commit 02d0b2f31c
1 changed files with 6 additions and 18 deletions

View File

@ -97,25 +97,10 @@ __midentify__main() {
unset "$nextprefix$key" unset "$nextprefix$key"
done done
local output="$(${MPV:-mpv} --term-playing-msg="$propstr" --vo=null --ao=null \
--frames=1 --quiet --no-cache --no-config -- "$@")"
local fileindex=0 local fileindex=0
local prefix= local prefix=
while :; do local line
local line output while IFS= read -r line; do
case "$output" in
'')
break
;;
*"$LF"*)
line="${output%%$LF*}"
output="${output#*$LF}"
;;
*)
line="$output"
output=
;;
esac
case "$line" in case "$line" in
X-MIDENTIFY-START:) X-MIDENTIFY-START:)
if [ -n "$nextprefix" ]; then if [ -n "$nextprefix" ]; then
@ -154,7 +139,10 @@ __midentify__main() {
fi fi
;; ;;
esac esac
done done <<EOF
$(${MPV:-mpv} --term-playing-msg="$propstr" --vo=null --ao=null \
--frames=1 --quiet --no-cache --no-config -- "$@")
EOF
} }
__midentify__main "$@" __midentify__main "$@"