diff options
author | P. J. McDermott <pjm@nac.net> | 2012-10-25 23:27:49 (EDT) |
---|---|---|
committer | P. J. McDermott <pjm@nac.net> | 2012-10-25 23:27:49 (EDT) |
commit | 6c6e0021c1e6655ae79bfc2eb5303a71791fa478 (patch) | |
tree | 44c50c1a566bb166c1062c9943598466e6f54c18 /lib | |
parent | c06b1494a26f5274e72b04286cab28a5d0d7188d (diff) |
Improve formatting of dep in ob_parse_dep().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/deps.sh | 22 |
1 files changed, 16 insertions, 6 deletions
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 ${?} |