Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: let unset array element remove compatible with bash



[Moved to -workers for discussion]

On Feb 22,  3:28am, Daniel Lin wrote:
}
} Can any developer consider to enhance zsh's function like "unset var[2]"?

Hmm, what's the reason NOT to do this?  I can think of one: "unset var[9]"
might cause elements 2 through 8 to spring into existence, which is surely
counter-intuitive ... but of course the same thing happens with var[9]=().

@@ -3049,8 +3063,14 @@
 		}
 		paramtab = tht;
 	    } else {
-		zerrnam(name, "%s: invalid element for unset", s);
-		returnval = 1;
+		char *arr[1]; arr[0] = 0;
+		*ss = '[';
+		if (assignaparam(s, zarrdup(arr), 0)) {
+		    returnval = 0;
+		} else {
+		    zerrnam(name, "%s: invalid element for unset", s);
+		    returnval = 1;
+		}
 	    }
 	} else {
 	    if (unsetparam_pm(pm, 0, 1))



Messages sorted by: Reverse Date, Date, Thread, Author