summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrebs <krebs@fuerkrebs>2011-09-24 16:31:36 -0400
committerkrebs <krebs@fuerkrebs>2011-09-24 16:31:36 -0400
commit04e5f9847f8afd771ccc2410e2fb5e616aa1a4e9 (patch)
tree30158caa363649887f4e26e5fa553d912ddffb0c
parentf3409fb38be4cf0c84f6c2075cb67844cc58c93a (diff)
parent88212635961bac86a8c9c1b0626f8a016bcc9b70 (diff)
Merge branch 'master' of github.com:krebscode/painload
-rwxr-xr-xutil/bin/magic37
1 files changed, 37 insertions, 0 deletions
diff --git a/util/bin/magic b/util/bin/magic
new file mode 100755
index 00000000..218c8d43
--- /dev/null
+++ b/util/bin/magic
@@ -0,0 +1,37 @@
+#! /bin/sh
+#
+# magic name command file < content
+#
+
+bs="# begin krebs magic <$1>"
+es="# end krebs magic <$1>"
+
+case $1 in
+ (print)
+ echo "$bs"
+ cat
+ echo "$es"
+ ;;
+ (create)
+ $0 $1 has $3 || $0 $1 print $3 >> $3 < /dev/null
+ $0 $1 replace $3
+ ;;
+ (destroy)
+ if $0 $1 has $3; then
+ cache"`cat $3`"
+ echo "$cache" | sed "/^$bs$/,/^$es$/d" > $3
+ fi
+ ;;
+ (has)
+ grep -q "^$bs\$" $3 && grep -q "^$es\$" $3
+ ;;
+ (replace)
+ $0 $1 destroy $3 && $0 $1 create $3
+ ;;
+ (clear)
+ $0 $1 replace $3 < /dev/null
+ ;;
+ (*)
+ echo 'Error 1: You are made of stupid!' >&2
+ exit 23
+esac