more uniquifying
[feisty_meow.git] / scripts / core / functions.sh
index 1fe45e6c4d84cc2e8ea3ae242fcbf4ab5359d0d4..6c6832ae70e2d10f4fd7c2d30d346ac48304cc18 100644 (file)
@@ -80,6 +80,18 @@ if [ -z "$skip_all" ]; then
     IFS="$HOLDIFS"
   }
 
+  # when passed a list of things, this will return the unique items from that list as an echo.
+  function uniquify()
+  {
+    # change the eol character so things are easier.
+    HOLDIFS="$IFS"
+    IFS=' '
+    # do the uniquification.
+    echo $* | uniq
+    # return the former eol characters to their place.
+    IFS="$HOLDIFS"
+  }
+
   # sets the variable in parameter 1 to the value in parameter 2, but only if
   # that variable was undefined.
   function set_var_if_undefined()