help-bash
[Top][All Lists]
Advanced

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

Re: Help fixing NativeMessaging host: read 32-bit message length in nati


From: guest271314
Subject: Re: Help fixing NativeMessaging host: read 32-bit message length in native byte order
Date: Sat, 24 Jun 2023 19:34:57 -0700

Alright, I can verify

  length=$(dd iflag=fullblock bs=4 count=1 | od -An -td4)
  IFS= read -rN"$length" message

works.

What else in the code is GNU-specific?

Let's make sure we create a true non-GNU version now. What do we call it?

On Sat, Jun 24, 2023 at 4:27 PM Greg Wooledge <greg@wooledge.org> wrote:

> On Sat, Jun 24, 2023 at 03:32:10PM -0700, guest271314 wrote:
> > #!/bin/bash
> > getMessage() {
> >   length=$(head -q -z --bytes=4 -| od -An -td4 -)
> >   message=$(head -q -z --bytes=$((length)) -)
> >   sendMessage "$message"
> > }
>
> Does that actually work?  In my experience, head(1) reads a buffer
> full of input, even if it's only going to print a single line.  But
> maybe the GNU version acts differently when given the --bytes argument?
> If so, either congratulations are in order on your detective work,
> or else you got lucky.
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]