diff options
author | James Le Cuirot <chewi@aura-online.co.uk> | 2011-04-20 11:55:06 +0100 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2011-04-27 15:27:16 -0500 |
commit | 8fcaba9a22ac0deda7dc6a8d5f270d1df08f9966 (patch) | |
tree | af335dd607c07d2e63ea06fb7f698fa9ef0a2210 | |
parent | 04e256e3b82ed36f61c375d83f8631a7b58bf28c (diff) |
fix rc_service_extra_commands return value
If there were no extra commands, rc_service_extra_commands returned a
list containing a single empty string. This changes that to return an
empty list, which is more consistent with what you would expect.
X-Gentoo-Bug: 360013
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=360013
-rw-r--r-- | src/librc/librc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/librc/librc.c b/src/librc/librc.c index f2f694df..5feb5d7a 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -550,14 +550,16 @@ rc_service_extra_commands(const char *service) if ((fp = popen(cmd, "r"))) { rc_getline(&buffer, &len, fp); p = buffer; - while ((token = strsep(&p, " "))) { - if (!commands) - commands = rc_stringlist_new(); - rc_stringlist_add(commands, token); - } + commands = rc_stringlist_new(); + + while ((token = strsep(&p, " "))) + if (token[0] != '\0') + rc_stringlist_add(commands, token); + pclose(fp); free(buffer); } + free(cmd); return commands; } |