diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-10-14 10:55:42 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:58 +1000 |
commit | 22fc43c8dbca0205c854ae6e1c7f2c9c3c354125 (patch) | |
tree | 629b92bf8ebd6614a5deb40add48ba0bd27cd0b9 /jim.c | |
parent | 8c30b0e5f55f67425c6b83109d28823eb8fa38f5 (diff) | |
download | jimtcl-22fc43c8dbca0205c854ae6e1c7f2c9c3c354125.zip jimtcl-22fc43c8dbca0205c854ae6e1c7f2c9c3c354125.tar.gz jimtcl-22fc43c8dbca0205c854ae6e1c7f2c9c3c354125.tar.bz2 |
Fix error message for deleting nonexistent proc
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.c')
-rw-r--r-- | jim.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -3471,14 +3471,18 @@ int Jim_RenameCommand(Jim_Interp *interp, const char *oldName, const char *newNa { Jim_HashEntry *he; - if (newName[0] == '\0') /* Delete! */ - return Jim_DeleteCommand(interp, oldName); - /* Rename */ + /* Does it exist? */ he = Jim_FindHashEntry(&interp->commands, oldName); if (he == NULL) { - Jim_SetResultFormatted(interp, "can't rename \"%s\": command doesn't exist", oldName); + Jim_SetResultFormatted(interp, "can't %s \"%s\": command doesn't exist", + newName[0] ? "rename" : "delete", oldName); return JIM_ERR; } + + if (newName[0] == '\0') /* Delete! */ + return Jim_DeleteCommand(interp, oldName); + + /* rename */ if (Jim_FindHashEntry(&interp->commands, newName)) { Jim_SetResultFormatted(interp, "can't rename to \"%s\": command already exists", newName); return JIM_ERR; |