summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorkrebs <krebs@fuerkrebs>2011-11-08 17:12:25 -0500
committerkrebs <krebs@fuerkrebs>2011-11-08 17:12:25 -0500
commitcff7c75150454226b8cbb77f3daf6fdabd8a28eb (patch)
tree4eaffe2fe9f1aad6c48657cf0e8123504f961571 /util
parent207a4ec405d3229a9d2e200b7803c3068d513265 (diff)
// magic: shuffle args
Diffstat (limited to 'util')
-rwxr-xr-xutil/bin/magic14
1 files changed, 5 insertions, 9 deletions
diff --git a/util/bin/magic b/util/bin/magic
index cb9cee6e..a404c0c3 100755
--- a/util/bin/magic
+++ b/util/bin/magic
@@ -1,12 +1,8 @@
#! /bin/sh
-#
-# magic NAME create FILE < CONTENT
-# magic NAME update FILE < CONTENT
-# magic NAME destroy FILE
-#
+set -euf
-bs="# begin krebs magic <$1>"
-es="# end krebs magic <$1>"
+bs="# begin krebs magic <$2>"
+es="# end krebs magic <$2>"
has() {
grep -q "^$bs$" $3 && grep -q "^$es$" $3
@@ -37,7 +33,7 @@ destroy() {
}
help() {
cat <<EOF
-Usage: $0 DELIMITER_NAME FUNCTION FILE
+Usage: $0 FUNCTION DELIMITER_NAME FILE
$0 creates,updates or destroys magic inside a file.
It can be used to reliably add or remove custom lines.
For example add own lines in /etc/rc.local to auto-load
@@ -55,7 +51,7 @@ shell comment symbol "#".
EOF
}
-case $2 in
+case $1 in
(create) create "$@" ;;
(retrieve) retrieve "$@" ;;
(update) update "$@" ;;