diff options
author | Kevin McCarthy <kevin@8t8.us> | 2021-02-25 14:19:19 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2021-02-26 14:30:19 -0800 |
commit | de51ab4aacba08340d6d5dc8f2d18a5c28c7d0c3 (patch) | |
tree | db1898526879a80b04a477c77a5fdde384bef015 /init.c | |
parent | 0f8a2a137cd0c8c92b6d50c3218b0936447f1f2b (diff) |
Fix (un)setenv to not return an error with unset env vars.
The code was returning -1 in those cases. This can cause hook
processors, such as send2-hook, to sleep 1 second without an error
message being set and displayed. It also causes the hook processor to
abort executing subsequent matching commands.
-1 should be reserved for syntax errors. For setenv querying, change
the return value to 0. For unsetenv, generate a message and also
change the return value to 0.
<enter-command> checks if err->data is set to determine whether to
print anything, and the behavior is used in the 'set' commands, so
this is established correct behavior.
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -2144,7 +2144,7 @@ static int parse_setenv(BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFF } snprintf (err->data, err->dsize, _("%s is unset"), tmp->data); - return -1; + return 0; } if (unset) @@ -2168,7 +2168,9 @@ static int parse_setenv(BUFFER *tmp, BUFFER *s, union pointer_long_t udata, BUFF envp++; count++; } - return -1; + + snprintf (err->data, err->dsize, _("%s is unset"), tmp->data); + return 0; } /* set variable */ |