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

[PATCH] Make $options re-settable.



Follow-up to 40508.

Reported-by: James McGlashan
---
Received via IRC.

James also suggests adding fuzzing/codegen-based testing, e.g.,

for v in functions options ...; do
    $v+=() $v=() $v=(one_element)
    eval "$v+=() $v=() $v=(one_element)"
done

We should indeed check the other parameter.c special hashes for other
occurrences of this bug.  I haven't done so yet...

Cheers,

Daniel


 Src/Modules/parameter.c | 4 ++--
 Test/V06parameter.ztst  | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index c251e4f..c7aac88 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -937,7 +937,7 @@ unsetpmoption(Param pm, UNUSED(int exp))
 
 /**/
 static void
-setpmoptions(UNUSED(Param pm), HashTable ht)
+setpmoptions(Param pm, HashTable ht)
 {
     int i;
     HashNode hn;
@@ -962,7 +962,7 @@ setpmoptions(UNUSED(Param pm), HashTable ht)
 			      (val && strcmp(val, "off")), 0, opts))
 		zwarn("can't change option: %s", hn->nam);
 	}
-    deleteparamtable(ht);
+    hashsetfn(pm, ht);
 }
 
 static const struct gsu_scalar pmoption_gsu =
diff --git a/Test/V06parameter.ztst b/Test/V06parameter.ztst
index 27d5878..2b66713 100644
--- a/Test/V06parameter.ztst
+++ b/Test/V06parameter.ztst
@@ -92,6 +92,9 @@
 >foo
 >bar
 
+ options+=(); options+=()
+0:$options can be appended to twice
+
 %clean
 
  rm -f autofn functrace.zsh rocky3.zsh sourcedfile myfunc



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