delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/02/05/17:02:43

X-Spam-Check-By: sourceware.org
Message-ID: <45C7A901.8050004@cwilson.fastmail.fm>
Date: Mon, 05 Feb 2007 17:00:33 -0500
From: Charles Wilson <cygwin AT cwilson DOT fastmail DOT fm>
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: [patch] cygport-0.2.9 custom commands
References: <announce DOT 45C6C93F DOT 706 AT users DOT sourceforge DOT net>
In-Reply-To: <announce.45C6C93F.706@users.sourceforge.net>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------000205060201050709030605
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Forward port to latest release.

For further history and justifiation of this patch, see 
http://cygwin.com/ml/cygwin/2007-01/msg00113.html and follow the 
embedded links and threads.

--
Chuck

2007-02-05  Charles Wilson  <...>

	* bin/cygport.in (custom_dummy_core): new function, used to test
	custom-command framework
	(custom_dummy): ditto
	(main): add implentation for custom-show) and customN-*)



--------------000205060201050709030605
Content-Type: text/plain;
 name="cygport-custom-cmds.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cygport-custom-cmds.patch"

Index: bin/cygport.in
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/bin/cygport.in,v
retrieving revision 1.53
diff -u -r1.53 cygport.in
--- bin/cygport.in	5 Feb 2007 03:28:43 -0000	1.53
+++ bin/cygport.in	5 Feb 2007 21:36:30 -0000
@@ -1650,11 +1650,38 @@
 
 ################################################################################
 #
+# test target for custom command hooks
+#
+################################################################################
+custom_dummy_core() {
+	local -i my_c=0
+	local -i my_argc=$#
+
+	while (( my_c < my_argc ))
+	do
+		my_c+=1
+		echo "${my_c}: $1"
+		shift
+	done
+}
+custom_dummy() {
+	inform "custom_dummy called with $# args"
+	custom_dummy_core "$@"
+}
+export -f custom_dummy_core custom_dummy
+readonly -f custom_dummy_core custom_dummy
+
+################################################################################
+#
 # End of functions
 #
 ################################################################################
 
 declare -i arg_n=2
+declare -i custom_arg_n
+declare -i custom_argc
+declare -a custom_args
+declare -x custom_cmd
 
 while (( arg_n < argc ))
 do
@@ -1731,6 +1758,46 @@
 			finish;
 			_status=$?;
 			;;
+		custom-show)
+			for fnc in $(set | sed -n '/()/s/()//p')
+			do
+				if test "$(type -t ${fnc})" == "function"
+				then
+					echo " ${fnc}"
+				fi
+			done
+			;;
+		custom0-* | custom1-* | custom2-* | custom3-* | custom4-* | \
+		custom5-* | custom6-* | custom7-* | custom8-* | custom9-* )
+			custom_argc=${argv[${arg_n}]:6:1}
+			custom_cmd=${argv[${arg_n}]:8}
+			if [ -z "${custom_cmd}" ]
+			then
+				error "${argv[${arg_n}]}* command has no target following the 'custom${custom_argc}-'"
+			fi
+
+			# consume arguments
+			custom_arg_n=0
+			while (( custom_arg_n < custom_argc )) && (( arg_n+1 < argc ))
+			do
+				arg_n+=1
+				custom_args[${custom_arg_n}]="${argv[${arg_n}]}"
+				custom_arg_n+=1
+			done
+			if (( custom_arg_n < custom_argc ))
+			then
+				error "custom${custom_argc} command ${custom_cmd}: not enough arguments"
+			fi
+			
+			if test "$(type -t ${custom_cmd})" == "function"
+			then
+				__stage ${custom_cmd} && eval "${custom_cmd} ${custom_args[@]}"
+				_status=$?;
+			else
+				error "${custom_cmd} is not a shell function"
+			fi
+			unset custom_args
+			;;
 		help)
 			__show_help;
 			exit 0;


--------------000205060201050709030605
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--------------000205060201050709030605--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019