Index: bin/cygport.in =================================================================== RCS file: /cvsroot/cygwin-ports/cygport/bin/cygport.in,v retrieving revision 1.45 diff -u -r1.45 cygport.in --- bin/cygport.in 4 Jan 2007 02:35:26 -0000 1.45 +++ bin/cygport.in 6 Jan 2007 04:50:07 -0000 @@ -1644,11 +1644,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 @@ -1721,6 +1748,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;