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 16:33:03 -0700

Yes, it works as expected.

Only took me a few years and thousands of manual tets to figure out.

I just happen to have been involved in a semi-related project
https://github.com/guest271314/fs/blob/main/bash/watcher.sh over the past
week or so where I used tail and head and remembered the bytes option and
what the author of the SO post I interpreted as a challenge to find out if
it can be done in Bash said re bytes.

Test for yourself to verify the code echoes new Array(209715) (1 MB)
https://github.com/guest271314/native-messaging-bash. I invite vetting of
my claims; I vet everybody's claims, without exception.

Thank you so much for your help in this matter!


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.
>
>

Attachment: Screenshot_2023-06-24_15-31-13.png
Description: PNG image


reply via email to

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