diff options
-rw-r--r-- | jim-array.c | 5 | ||||
-rw-r--r-- | regtest.tcl | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/jim-array.c b/jim-array.c index bf07e07..39cd168 100644 --- a/jim-array.c +++ b/jim-array.c @@ -109,6 +109,11 @@ static int array_cmd_unset(Jim_Interp *interp, int argc, Jim_Obj *const *argv) objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE); + if (objPtr == NULL) { + /* Doesn't exist, so nothing to do */ + return JIM_OK; + } + if (Jim_DictPairs(interp, objPtr, &dictValuesObj, &len) != JIM_OK) { return JIM_ERR; } diff --git a/regtest.tcl b/regtest.tcl index a2a398f..3aaf3d2 100644 --- a/regtest.tcl +++ b/regtest.tcl @@ -233,6 +233,11 @@ proc c {} {} catch -eval a puts "TEST 32 PASSED" +# REGTEST 33 +# unset array variable which doesn't exist +array unset blahblah abc +puts "TEST 33 PASSED" + # TAKE THE FOLLOWING puts AS LAST LINE puts "--- ALL TESTS PASSED ---" |