Skip to content

Commit

Permalink
Cleanup: added `.sh' suffix; addresses #30
Browse files Browse the repository at this point in the history
  • Loading branch information
nima committed Mar 6, 2014
1 parent fa4823e commit ceb25b0
Show file tree
Hide file tree
Showing 21 changed files with 20 additions and 19 deletions.
22 changes: 11 additions & 11 deletions lib/libsh/libsite/libsite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ unset CDPATH
export SITE_DEADMAN=${SITE_USER_CACHE}/deadman
export SITE_IN_COLOR=1
export SITE_DATE_FORMAT="%x-%X"
source ${SITE_CORE_MOD?}/cpf
source ${SITE_CORE_MOD?}/cpf.sh
#. }=-
#. 1.7 Error Code Constants -={
true
Expand Down Expand Up @@ -215,9 +215,9 @@ function core:softimport() {
local module=$1
if [ -z "${g_SITE_IMPORTED_EXIT[${module}]}" ]; then
if [ ${USER_MODULES[${module}]-9} -eq 1 ]; then
if [ -f ${SITE_USER_MOD}/${module} ]; then
if ( source ${SITE_USER_MOD}/${module} >/tmp/site.${module}.ouch 2>&1 ); then
source ${SITE_USER_MOD}/${module}
if [ -f ${SITE_USER_MOD}/${module}.sh ]; then
if ( source ${SITE_USER_MOD}/${module}.sh >/tmp/site.${module}.ouch 2>&1 ); then
source ${SITE_USER_MOD}/${module}.sh
e=${CODE_IMPORT_GOOOD?}
else
e=${CODE_IMPORT_ERROR?}
Expand All @@ -227,9 +227,9 @@ function core:softimport() {
e=${CODE_IMPORT_UNDEF?}
fi
elif [ ${CORE_MODULES[${module}]-9} -eq 1 ]; then
if [ -f ${SITE_CORE_MOD}/${module} ]; then
if ( source ${SITE_CORE_MOD}/${module} >/tmp/site.${module}.ouch 2>&1 ); then
source ${SITE_CORE_MOD}/${module}
if [ -f ${SITE_CORE_MOD}/${module}.sh ]; then
if ( source ${SITE_CORE_MOD}/${module}.sh >/tmp/site.${module}.ouch 2>&1 ); then
source ${SITE_CORE_MOD}/${module}.sh
e=${CODE_IMPORT_GOOOD?}
else
e=${CODE_IMPORT_ERROR?}
Expand Down Expand Up @@ -289,13 +289,13 @@ function core:docstring() {

e=2 #. No such module
if [ ${USER_MODULES[${module}]-9} -eq 1 ]; then
if [ -f ${SITE_USER_MOD}/${module} ]; then
sed -ne '/^:<<\['${FUNCNAME}'\]/,/\['${FUNCNAME}'\]/{n;p;q}' ${SITE_USER_MOD}/${module}
if [ -f ${SITE_USER_MOD}/${module}.sh ]; then
sed -ne '/^:<<\['${FUNCNAME}'\]/,/\['${FUNCNAME}'\]/{n;p;q}' ${SITE_USER_MOD}/${module}.sh
e=$?
fi
elif [ ${CORE_MODULES[${module}]-9} -eq 1 ]; then
if [ -f ${SITE_CORE_MOD}/${module} ]; then
sed -ne '/^:<<\['${FUNCNAME}'\]/,/\['${FUNCNAME}'\]/{n;p;q}' ${SITE_CORE_MOD}/${module}
if [ -f ${SITE_CORE_MOD}/${module}.sh ]; then
sed -ne '/^:<<\['${FUNCNAME}'\]/,/\['${FUNCNAME}'\]/{n;p;q}' ${SITE_CORE_MOD}/${module}.sh
e=$?
fi
elif [ ${CORE_MODULES[${module}]-9} -eq 0 -o ${USER_MODULES[${module}]-9} -eq 0 ]; then
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 9 additions & 8 deletions module/unit → module/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ function testCoverage() {
cpf "%{@profile:${profile}}: %{!module:${module}} %{r:-=[}\n"
for context in private internal public; do
local regex=$(printf "${fnregexes[${context}]}" ${module})
local -i count=$(grep -cE "${regex}" ${module})
local -i count=$(grep -cE "${regex}" ${module}.sh)
cpf " %{m:${context}}:%{!module:${module}}:%{@int:${count} functions}\n"
if [ $count -gt 0 ]; then
local -a fns=(
$(grep -oE "${regex}" ${module} |
$(grep -oE "${regex}" ${module}.sh |
sed -e "s/^function :\{0,2\}${module}:\([^.()]\+\)\(\.[a-z]\+\)\?()/\1/")
)
for fn in ${fns[@]}; do
Expand Down Expand Up @@ -428,8 +428,9 @@ function ::unit:test() {
for profile in ${!profiles[@]}; do
if [ -d ${profiles[${profile}]} ]; then
cd ${profiles[${profile}]}
local module script
for module in *; do
local modulesh module script
for modulesh in *; do
module=${modulesh/.sh/}
if [ ${#g_MODULES[@]} -eq 0 -o ${g_MODULES[${module}]--1} -eq 1 ]; then
g_MODE="prime"
cpf "%{@comment:${profile}.${module}}.%{r:${g_MODE?} -=[}\n";
Expand All @@ -451,7 +452,7 @@ function ::unit:test() {
cat "${script}" > ${g_RUNTIME_SCRIPT?}
fi
source ${g_RUNTIME_SCRIPT?}
SHUNIT_PARENT="${SITE_CORE_MOD?}/unit" source ${SHUNIT2?}
SHUNIT_PARENT="${SITE_CORE_MOD?}/unit.sh" source ${SHUNIT2?}
)
local -i ep=$?

Expand Down Expand Up @@ -499,7 +500,7 @@ function unit:test() {
local -i e=${CODE_DEFAULT?}

if [ "${CITM_HOST:-false}" == "d41d8cd98f00b204e9800998ecf8427e" ]; then
local valid=1
e=${CODE_SUCCESS?}

local module
if [ $# -gt 0 ]; then
Expand All @@ -508,12 +509,12 @@ function unit:test() {
g_MODULES[${module}]=1
else
g_MODULES[${module}]=0
valid=0
e=${CODE_FAILURE?}
fi
done
fi

if [ ${valid} -eq 1 ]; then
if [ $e -eq ${CODE_SUCCESS?} ]; then
if [ -e "${SHUNIT2?}" ]; then
cpf "%{@comment:#############################################################################}\n"
#. Only regenerate the script if it doesn't exist, or if it is
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ceb25b0

Please sign in to comment.