From b8bf49ab7c95dc884b34df72a688ac241a2dcffc Mon Sep 17 00:00:00 2001 From: ranma Date: Thu, 30 Jun 2005 00:46:21 +0000 Subject: Better approach to shell escaping, may not catch all cases yet git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15858 b3059339-0415-0410-9bf9-f77b7e298cf2 --- TOOLS/midentify | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/TOOLS/midentify b/TOOLS/midentify index f6dbf21be3..99fe723631 100755 --- a/TOOLS/midentify +++ b/TOOLS/midentify @@ -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 }' -- cgit v1.2.3