[PATCH 1/4] Add '-0 / --print0' to herbstclient

Thorsten Wißmann edu at thorsten-wissmann.de
Wed Jun 25 12:21:27 CEST 2014


Hi Florian,

On Wed, Jun 25, 2014 at 11:33:52AM +0200, Florian Schmaus wrote:
>  *-n*, *--no-newline*::
>      Do not print a newline if output does not end with a newline.
>  
> +*-0*, *--print0*::
> +    Use the null character as output delimiter. This option implies *-n*.

That isn't stated quite clear in the man page (my mistake). The -n
option only affects the mode of executing some hlwm command but not the
mode of listening for hooks (So I have to fix this later). Furthermore,
I don't know what an ouptut delimiter is: is it the delimiter between
hooks or between the arguments of a hook?

> +            case '0':
> +                g_null_char_as_delim = true;
> +                // '-0' implies '-n'
> +                g_ensure_newline = 0;
> +                break;

As stated above, g_ensure_newline never occurs in the hook-code, so we
can just drop this.

> -        if (g_ensure_newline) {
> +        if (g_null_char_as_delim) {
> +            fputc(0, file);
> +        } else if (g_ensure_newline) {

Well this code is senseless: 'hc -0 CMD' acts like 'hc CMD' and then
appends the null-byte to its output. If you don't have an application
where you need this, I'd suggest:

  - make -0 affect only the --idle/--wait mode
  - state it clear in the man page
  - adjust code accordingly

If you want me to do that (in your name) while applying your patch, just
ping me via irc/mail. Otherwise just resubmit the new patch. Afterwards
I'll merge the --last-arg-patch (it looks fine).

Cheers,
Thorsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 213 bytes
Desc: not available
URL: <https://listi.jpberlin.de/pipermail/hlwm/attachments/20140625/f5911e23/attachment.sig>


More information about the hlwm mailing list