[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] Add '-l / --last-arg' to herbstclient



On Mon, Jun 30, 2014 at 11:55 AM, Thorsten Wißmann <edu _at_ thorsten _minus_ wissmann _dot_ de> wrote:
Hi,

On Wed, Jun 25, 2014 at 01:09:44PM +0200, Florian Schmaus wrote:
>          if (print_signal) {
> -            // just print as list
> -            for (int i = 0; i < hook_argc; i++) {
> -                printf("%s%s", i ? "\t" : "", hook_argv[i]);
> +            if (g_print_last_arg_only) {
> +                // This assumes that hook_argc is always > 0!
> +                printf("%s", hook_argv[hook_argc-1]);
> +            } else {

Don't assume it, check it :). I've just added a check for it such that
"empty" hooks are simply dropped.

I figured you would guarantee it. :) But of course, checking the preconditions is always a
good idea!

Best,
 Florian