changeset 15857:70ad5a19d831

Better approach to shell escaping, may not catch all cases yet
author ranma
date Thu, 30 Jun 2005 00:46:21 +0000
parents c41a88cd6886
children 045f91e5e67d
files TOOLS/midentify
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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 <ranma+mplayer@tdiedrich.de>
+# Licensed under GNU GPL.
+
+if [ -z "$1" ]; then
+	echo "Usage: midentify <file> [<file> ...]"
+	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 }'