summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/params.c17
-rw-r--r--Src/subst.c13
2 files changed, 30 insertions, 0 deletions
diff --git a/Src/params.c b/Src/params.c
index 22346896d..cb08b4e6a 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2490,6 +2490,23 @@ uniqarray(char **x)
 	    }
 }
 
+/**/
+void
+zhuniqarray(char **x)
+{
+    char **t, **p = x;
+
+    if (!x || !*x)
+	return;
+    while (*++p)
+	for (t = x; t < p; t++)
+	    if (!strcmp(*p, *t)) {
+		*p = NULL;
+		for (t = p--; (*t = t[1]) != NULL; t++);
+		break;
+	    }
+}
+
 /* Function to get value of special parameter `#' and `ARGC' */
 
 /**/
diff --git a/Src/subst.c b/Src/subst.c
index a42b81358..9a59495d0 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -767,6 +767,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
     int flags = 0;
     int flnum = 0;
     int sortit = 0, casind = 0;
+    int unique = 0;
     int casmod = 0;
     int quotemod = 0, quotetype = 0, quoteerr = 0;
     int visiblemod = 0;
@@ -996,6 +997,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		    shsplit = 1;
 		    break;
 
+		case 'n':
+		    unique = 1;
+		    break;
+
 		default:
 		  flagerr:
 		    zerr("error in flags", NULL, 0);
@@ -1873,6 +1878,14 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 	    setdata(n, y);
 	    return n;
 	}
+	if (unique) {
+/*	    if(!copied) */
+		aval = arrdup(aval);
+
+	    i = arrlen(aval);
+	    if (i > 1)
+		zhuniqarray(aval);
+	}
 	if (sortit) {
 	    static CompareFn sortfn[] = {
 		strpcmp, invstrpcmp, cstrpcmp, invcstrpcmp