aboutsummaryrefslogtreecommitdiff
path: root/trunk/src/mkbuild
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/src/mkbuild')
-rwxr-xr-xtrunk/src/mkbuild51
1 files changed, 44 insertions, 7 deletions
diff --git a/trunk/src/mkbuild b/trunk/src/mkbuild
index 11f0785..65c4c5b 100755
--- a/trunk/src/mkbuild
+++ b/trunk/src/mkbuild
@@ -90,6 +90,8 @@ ${red}DESCRIPTION${normal}
program version
${red}-V${normal}, ${red}--verbose${normal}
print debug information
+ ${red}-e${normal}, ${red}--edit${normal}
+ edit a mkbuild
${red}EXAMPLES${normal}
${red}mkbuild -sa pyrex.mkbuild${normal}
@@ -186,6 +188,12 @@ function set_parameters {
[ ${MKBUILD_NAME:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR "--search <mkbuild_name>"
ACTION='search'
;;
+ '-e'|'--edit')
+ # Open mkbuild with $EDITOR
+ MKBUILD_NAME="${2//.mkbuild}.mkbuild"
+ [ ${MKBUILD_NAME:0:1} = "-" ] && handle_error $ERROR_MKBUILD_INPUT_PAR "--edit <mkbuild_name>"
+ ACTION='edit'
+ ;;
'-d'|'--debug')
# Debug mode
set -x
@@ -1325,6 +1333,38 @@ function create_mkbuild {
}
+function search_mkbuild {
+
+ # find a given mkbuild
+ # usage: search_mkbuild
+
+ find $MKBUILDS_DIR -iname $MKBUILD_NAME
+
+}
+
+function edit_mkbuild {
+
+ # edit a mkbuild
+ # usage: edit_mkbuild
+
+ local match search="`search_mkbuild`"
+
+ if [ ! -z "$search" ]; then
+ for match in $search; do
+ # Edit the first matching mkbuild
+ if [ -z "$EDITOR" ]; then
+ EDITOR="vi"
+ fi
+ $EDITOR $match
+ break
+ done
+ else
+ echo "Not found: $MKBUILD_NAME"
+ return 1
+ fi
+
+}
+
# ----------------------------------------------------------------
#=============================
@@ -1404,13 +1444,10 @@ if [ ! -z "$MKBUILD_NAME" ]; then
make_slackbuild
;;
'search')
- SEARCH=`find $MKBUILDS_DIR -iname $MKBUILD_NAME`
- if [ "$SEARCH" == "" ]; then
- EXIT_CODE=1
- else
- EXIT_CODE=0
- echo $SEARCH
- fi
+ search_mkbuild
+ ;;
+ 'edit')
+ edit_mkbuild
;;
esac
fi