From 6c6e0021c1e6655ae79bfc2eb5303a71791fa478 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 25 Oct 2012 23:27:49 -0400 Subject: Improve formatting of dep in ob_parse_dep(). --- (limited to 'lib') diff --git a/lib/deps.sh b/lib/deps.sh index 5584e65..a423413 100644 --- a/lib/deps.sh +++ b/lib/deps.sh @@ -90,12 +90,22 @@ ob_parse_dep() shift $(($OPTIND - 1)) if [ ${#} -eq 1 ]; then - # Separate components with spaces. - _obpd_dep="$(echo "${1}" | \ - sed 's/\([(\[]\)/ \1/g;s/\([<>=][<>=]*\)/\1 /g')" - # Remove leading, trailing, and duplicate spaces. - _obpd_dep="$(echo "${_obpd_dep}" | \ - sed 's/\t/ /g;s/^ *//;s/ *$//;s/ */ /g') " + _obpd_dep="$(printf '%s\n' "${1}" | sed -n ' + H; # Store each input line in the hold space. + ${ + g; # Restore everything to the pattern space. + s/[\t\n]/ /g; # Replace tabs and newlines with spaces. + s/ *\([(\[<]\) */ \1/g; # One space before "(", "[", and "<". + s/ *\([)\]>]\) */\1 /g; # One space after "(", "[", and "<". + s/ *\(<[<=]\) */\1 /g; # One space after "<<" and "<=". + s/ *\(>[>=]\) */\1 /g; # One space after ">>" and ">=". + s/ *\(=\) */\1 /g; # One space after "=". + s/^ *//; # Remove leading spaces. + s/ *$//; # Remove trailing spaces. + s/ */ /g; # Remove duplicate spaces. + p; # Print the pattern space. + }; + ')" else _ob_return 125 return ${?} -- cgit v0.9.1