"contains" function
This commit is contained in:
parent
f01c7f9b53
commit
9ce5c45bed
28
urchin
28
urchin
@ -257,6 +257,17 @@ fullpath() {
|
|||||||
readlink -f -- "${1}"
|
readlink -f -- "${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contains() {
|
||||||
|
case "$#" in
|
||||||
|
1) grep "${1}" > /dev/null ;;
|
||||||
|
2) echo "${1}" | contains "${2}" ;;
|
||||||
|
3) contains "${1}" "${2}" && contains "${1}" "${3}" ;;
|
||||||
|
*) container="${1}" && shift
|
||||||
|
contains "${container}" "${1}" && shift &&
|
||||||
|
contains "${container}" "${@}" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
remove_trailing_slash() {
|
remove_trailing_slash() {
|
||||||
echo "$1" | sed s/\\/$//
|
echo "$1" | sed s/\\/$//
|
||||||
}
|
}
|
||||||
@ -304,8 +315,8 @@ recurse() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if echo "${requested_path}" | grep -q "^${potential_test}" ||
|
if contains "${potential_test}" "^${potential_test}" ||
|
||||||
echo "${potential_test}" | grep -q "^${requested_path}" ; then
|
contains "${potential_test}" "^${requested_path}" ; then
|
||||||
if test "$(dirname "${potential_test}")" = \
|
if test "$(dirname "${potential_test}")" = \
|
||||||
"$(dirname "${requested_path}")" &&
|
"$(dirname "${requested_path}")" &&
|
||||||
test "${potential_test}" != "${requested_path}"; then
|
test "${potential_test}" != "${requested_path}"; then
|
||||||
@ -315,7 +326,7 @@ recurse() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "${potential_test}" grep "${DELIMITERS}" > /dev/null; then
|
if contains "${potential_test}" "${DELIMITERS}"; then
|
||||||
echo 'Test file names may not contain ASCII delimiters.' >&2
|
echo 'Test file names may not contain ASCII delimiters.' >&2
|
||||||
urchin_exit 11
|
urchin_exit 11
|
||||||
fi
|
fi
|
||||||
@ -602,14 +613,12 @@ main() {
|
|||||||
urchin_exit 11
|
urchin_exit 11
|
||||||
}
|
}
|
||||||
|
|
||||||
if echo "${shell_for_sh_tests}" |
|
if contains "${potential_test}" "${DELIMITERS}"; then
|
||||||
grep "${DELIMITER}" > /dev/null; then
|
|
||||||
echo Shell paths may not contain the delimiter characters. >&2
|
echo Shell paths may not contain the delimiter characters. >&2
|
||||||
urchin_exit 11
|
urchin_exit 11
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "${shell_for_sh_tests}" |
|
if contains "${shell_for_sh_tests}" "[${IFS}]"; then
|
||||||
grep "[${IFS}]" > /dev/null; then
|
|
||||||
echo "Warning: It is best if field-separator characters
|
echo "Warning: It is best if field-separator characters
|
||||||
(usually spaces) are absent from shell paths so that
|
(usually spaces) are absent from shell paths so that
|
||||||
you don't need to quote the TEST_SHELL variable." >&2
|
you don't need to quote the TEST_SHELL variable." >&2
|
||||||
@ -622,10 +631,7 @@ you don't need to quote the TEST_SHELL variable." >&2
|
|||||||
-T|--timeout)
|
-T|--timeout)
|
||||||
shift
|
shift
|
||||||
urchin_timeout="${1}"
|
urchin_timeout="${1}"
|
||||||
if ! {
|
if ! contains "${urchin_timeout}" '[0-9][0-9.]*\(s\|m\|h\|d\|\)' ; then
|
||||||
echo "${urchin_timeout}" |
|
|
||||||
grep '[0-9][0-9.]*\(s\|m\|h\|d\|\)'
|
|
||||||
}; then
|
|
||||||
echo Bad timeout argument: "${urchin_timeout}" >&2
|
echo Bad timeout argument: "${urchin_timeout}" >&2
|
||||||
urchin_exit 1
|
urchin_exit 1
|
||||||
fi ;;
|
fi ;;
|
||||||
|
Loading…
Reference in New Issue
Block a user