diff options
author | sabetts <sabetts> | 2004-10-05 20:57:31 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2004-10-05 20:57:31 +0000 |
commit | a2aeb8461a435621330a692998237f259c356640 (patch) | |
tree | fac0c7b51d71fae0f6c1863c03a7bbee9e96e335 /src | |
parent | f4db5f65334718728090283acbb5b99f4895a469 (diff) | |
download | ratpoison-a2aeb8461a435621330a692998237f259c356640.zip |
* src/actions.c (cmd_unsetenv): add an '=' to the string passed to
putenv.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.c | 12 | ||||
-rw-r--r-- | src/sbuf.c | 15 | ||||
-rw-r--r-- | src/sbuf.h | 1 |
3 files changed, 26 insertions, 2 deletions
diff --git a/src/actions.c b/src/actions.c index 2f53294..9c97332 100644 --- a/src/actions.c +++ b/src/actions.c @@ -2753,14 +2753,22 @@ cmd_chdir (int interactive, char *data) char * cmd_unsetenv (int interactive, char *data) { + struct sbuf *s; + char *str; + if (data == NULL) { message (" unsetenv: one argument is required "); return NULL; } - /* Remove all instances of the env. var. */ - putenv (data); + /* Remove all instances of the env. var. We must add an '=' for it + to work on OpenBSD. */ + s = sbuf_new(0); + sbuf_copy (s, data); + sbuf_concat (s, "="); + str = sbuf_free_struct (s); + putenv (str); return NULL; } @@ -53,6 +53,21 @@ sbuf_free (struct sbuf *b) } } +/* Free the structure but return the string. */ +char * +sbuf_free_struct (struct sbuf *b) +{ + if (b != NULL) + { + char *tmp; + tmp = b->data; + free (b); + return tmp; + } + + return NULL; +} + char * sbuf_concat (struct sbuf *b, const char *str) { @@ -37,6 +37,7 @@ sbuf struct sbuf *sbuf_new (size_t initsz); void sbuf_free (struct sbuf *b); +char *sbuf_free_struct (struct sbuf *b); char *sbuf_concat (struct sbuf *b, const char *str); char *sbuf_copy (struct sbuf *b, const char *str); char *sbuf_clear (struct sbuf *b); |