# HG changeset patch # User ranma # Date 1120092381 0 # Node ID 70ad5a19d8314cfabf0a0e0c1129f5c4ad850741 # Parent c41a88cd688612fbb20840fef40eabeb32b205a6 Better approach to shell escaping, may not catch all cases yet diff -r c41a88cd6886 -r 70ad5a19d831 TOOLS/midentify --- a/TOOLS/midentify Wed Jun 29 23:28:36 2005 +0000 +++ b/TOOLS/midentify Thu Jun 30 00:46:21 2005 +0000 @@ -1,5 +1,16 @@ #!/bin/sh +# +# This is a wrapper around the -identify functionality. +# It is supposed to escape the output properly, so it can be easily +# used in shellscripts by 'eval'ing the output of this script. +# +# Written by Tobias Diedrich +# Licensed under GNU GPL. + +if [ -z "$1" ]; then + echo "Usage: midentify [ ...]" + exit 1 +fi + mplayer -vo null -ao null -frames 0 -identify "$@" 2>/dev/null | - grep "^ID" | - sed -e 's/[`\\!$"]/\\&/g' | - sed -e '/^ID_FILENAME/ { s/^ID_FILENAME=\(.*\)/ID_FILENAME="\1"/g; }' + sed -ne '/^ID_/ {s/[]`\\!$" []/\\&/g;p }'