summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/deps.sh22
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 ${?}