News for hackers. Stuff that matters.
Re:GNU poke 1.0 by Aissen on Friday February 26, 2021 @01:36PM (#26278124)
GNU poke is already really promising. You can have a look at this presentation from Kernel Recipes 2019 to get a rough idea of what it looked like ~two years ago:

https://www.youtube.com/watch?v=92Sykut06N8

Think of it as the missing tool between an hex editor and a programming language. Hachoir, Kaitai, linker scripts or most reverse engineering toolkits (radare, etc.) all try to address a similar problem, but from a different angle.

Re:GNU poke 1.0 by chungy on Friday February 26, 2021 @02:51PM (#26279080)
Is this named after the old BASIC command "poke" on micros of the 80s?

This program looks pretty awesome and seems to fit into a use-case that I frequently want. I've usually just consigned myself to using standard hex editors, sometimes little bits of Python to wrangle whatever data I'm trying to manage.

Re:GNU poke 1.0 by nocman on Friday February 26, 2021 @04:48PM (#26280241)
That was the first thing that came to mind for me.

Shouldn't it also have a companion utility named peek?

:-D

Re:GNU poke 1.0 by Brian_K_White on Friday February 26, 2021 @09:07PM (#26282028)
If you combime poke and peek you could get "poek" still pronounced poke, and also have a little allusion to elegance by being almost "poet".

Honestly I don't suggest that, just having fun. Simple is good in a name. Then again, so is a unique search term.

Re:GNU poke 1.0 by adamrezich on Friday February 26, 2021 @07:34PM (#26281511)
Sounds like a better version of the old MS-DOS DEBUG.EXE to me, which for some reason I saw fit to use on explorer.exe on my dad's old WinBook XP running Windows 95 back in the day...
Re:GNU poke 1.0 by SloopJon on Friday February 26, 2021 @01:38PM (#26278146)
One thing I haven't had much success with when trying editors like this is dealing with variable data, like Pascal-style strings or varints. Another one is a length field that is either one byte, or a NUL byte followed by two bytes, or three NUL bytes followed by four bytes.

I'll have to give this one a try. It would be nice to be able to sift through binary data like bytecode or some non-standard serialization format without writing a one-off utility for it.

Re:GNU poke 1.0 by digikata on Friday February 26, 2021 @03:13PM (#26279331)
I recently tried Kaitai for something like this. It worked for some nontrivial cases, but I felt like I kept getting bitten by syntax limitations. All the way through, I kept wondering if writing a one off utility might be faster. But it was possible to express variable structures, sizes and counts. I was using the syntax and the cmd line visualizer, but might have been more productive with their html/gui tooling.

http://kaitai.io/

Re:GNU poke 1.0 by kenny11 on Friday February 26, 2021 @02:27PM (#26278773)
I spent a long time looking for something similar to sift through binary files and found this:

https://www.sweetscape.com/010editor/

It lets you write "templates" in a weird hybrid syntax that looks a lot like a C header file but also allows control statements that can decode complicated data structures in a few lines of script. It looks to have very similar capabilities to GNU Poke, but with a GUI.

Re:GNU poke 1.0 by chris_wot on Friday February 26, 2021 @04:36PM (#26280096)
The poke creator seems to have a very dim view of 010.
Re:GNU poke 1.0 by rurban on Saturday February 27, 2021 @12:00PM (#26286140)
Exactly. Much worse syntax choices. Would not want to spend my time with it, when I have much more with 101.

But it least the VM is much faster than 101

Re:GNU poke 1.0 by kodachi on Friday February 26, 2021 @09:32PM (#26282117)
https://ide.kaitai.io/ has a yaml syntax, and its online editor has tons of examples.
Re:GNU poke 1.0 by badsectoracula on Saturday February 27, 2021 @12:30AM (#26282904)
I skimmed through the manual and from what i can tell this seems to be more of a language (with a REPL) with support for handling data streams (they call them I/O Spaces for some reason) than an editor. There does seem to be support for declaring types of variable length and it is one of the first examples:

    type Packet =
      struct
      {
        byte magic;
        uint<16> length;
        byte[length] data;
      }
It also seems to have optional fields using conditions, using the optional extended header in MP3 id3v2 tag as an example:

    struct ID3V2_Tag =
      struct
      {
        ID3V2_Hdr hdr;
        IDV2_Ext_Hdr ext_hdr if hdr.extended_hdr_present;
      }
(this is an alternative to another way it provides by using unions which work similar to C unions but each alternative also has conditions for when it is valid).

So at least from the above i think it should be possible to declare types that work with variable length and prefixes like that.

Re:GNU poke 1.0 by begoon on Friday February 26, 2021 @01:45PM (#26278209)
It reminded my radare2 when it had just started.
Re:GNU poke 1.0 by colejohnson66 on Friday February 26, 2021 @02:59PM (#26279166)
It reminds me of 010 Editor. A programming language to describe structures is exactly what 010 Editor had (they were called “Binary Templates”). It allowed awesome things like: this next sequence of bytes is interpreted differently depending on the previously encountered bytes. For example, here’s the EXE file format: https://www.sweetscape.com/010editor/repository/files/EXE.bt
Re:GNU poke 1.0 by matheusmoreira on Friday February 26, 2021 @10:44PM (#26282403)
Can we write data structure libraries? Making a save game editor for old games I like was the first thing that came to mind.
Re:GNU poke 1.0 by pierrebai on Friday February 26, 2021 @11:30PM (#26282578)
The example in section 1.1.2 Describe-Compute has number of bytes all wrong. I read 4 bytes for 16 bits, 8 for 32 bits...
Re:GNU poke 1.0 by ajarmst on Friday February 26, 2021 @04:30PM (#26280046)
Gnu has released an editor without including an associated emacs mode? I’m sorry, that’s just not acceptable.
Re:GNU poke 1.0 by pjscott on Friday February 26, 2021 @05:43PM (#26280750)
Did you check? poke-mode.el is part of their source repo:

https://git.savannah.gnu.org/cgit/poke.git/tree/etc/poke-mod...

Re:GNU poke 1.0 by ajarmst on Saturday February 27, 2021 @02:28PM (#26287430)
Yeah. Couldn’t find it. As always, the fastest way to get a correct answer to a question is to post an incorrect one. Thanks.
Re:GNU poke 1.0 by swiley on Friday February 26, 2021 @05:32PM (#26280640)
Also no guile scripting.
Re:GNU poke 1.0 by jtvjan on Friday February 26, 2021 @01:19PM (#26277929)
Oh. I thought it was a free software, federated implementation of Facebook's "poking" feature.
Re:GNU poke 1.0 by pwdisswordfish0 on Friday February 26, 2021 @02:59PM (#26279164)
Please, folks, stop posting these "I thought this was going to be about X" comments.
Re:GNU poke 1.0 by Hackbraten on Friday February 26, 2021 @04:42PM (#26280174)
I’m never going to understand why HN frowns upon humor so much.
Re:GNU poke 1.0 by tpush on Friday February 26, 2021 @08:32PM (#26281857)
Humor is fine. Humor as the only substance of a comment just wastes everyone's time.
Re:GNU poke 1.0 by Semiapies on Friday February 26, 2021 @11:42PM (#26282654)
Especially when this particular joke is never actually funny.
Re:GNU poke 1.0 by dkjaudyeqooe on Friday February 26, 2021 @04:54PM (#26280302)
Me neither. I think the trick is to make it really, really dry and deadpan, then the humourless don't even notice and others have can have a little chuckle.
Re:GNU poke 1.0 by carapace on Friday February 26, 2021 @07:29PM (#26281471)
If you don't quash quips it gets all redditty.
Re:GNU poke 1.0 by gjm11 on Saturday February 27, 2021 @09:45AM (#26285149)
As I have said before in response to similar comments: HN has no problem with humour. Where it differs from, say, typical reddits is that in order to get upvoted rather than dowvoted, humorous comments have to actually be funny.
Re:GNU poke 1.0 by vorpalhex on Friday February 26, 2021 @05:30PM (#26280622)
It's offtopic.
Re:GNU poke 1.0 by corobo on Friday February 26, 2021 @01:32PM (#26278073)
Combining the two (well, the name and your comment) I'd love a poke command that acts like tee but sends a notification when the calling process ends.

  ./backup.sh | poke username
Where username would accept a system user, phone number, email address, webhook url, whatever.
Re:GNU poke 1.0 by koolba on Friday February 26, 2021 @02:39PM (#26278921)
It should be reversed:

poke username -- path/to/command arg1 arg2

The command would fork, execute the child, wait for the child to finish, then send out its notification.

This would also allow flags like:

poke --on-failure @koolba -- path/to/foo

Or even handling the child taking too long:

poke --on-lagging 20m @koolba -- path/to/something-that-might-hang

Re:GNU poke 1.0 by jolmg on Friday February 26, 2021 @02:16PM (#26278627)
Is the point of the pipe that the notification should include the output of the command like the following?

  ./backup.sh | ( notify-send "$(cat)" )
though that could also be written:

  notify-send "$(./backup.sh)"
If you also want the output in the terminal, you could use tee:

  ./backup.sh | tee >(notify-send "$(cat)")
If you want it to be an email or SMS, there are probably commands that you could replace notify-send with.
Re:GNU poke 1.0 by corobo on Friday February 26, 2021 @02:25PM (#26278741)
Not really sure with pipe. It could probably just be &&'d with an optional message parameter to be fair.

Or sprinkle some AI on it and decide based on the destination. I wouldn't want a huge log being sent via sms but nbd for email.

Re:GNU poke 1.0 by jolmg on Friday February 26, 2021 @02:28PM (#26278792)
> Or sprinkle some AI on it and decide based on the destination.

Or avoid that overcomplication and specify what you want. As the one writing the command, you should know if the output is big and what the ideal is for the destination you want.

Re:GNU poke 1.0 by corobo on Friday February 26, 2021 @02:42PM (#26278969)
You don't have to make it for me haha. This is not a product specification and I am not a demanding customer. It's a hypothetical command that popped into my head while browsing a site with hacker in the name.

It's also a command I could throw together in about an hour with a bit of bash if I really wanted it. Mix in a bit of curl, bit of whatever the sendmail command is these days, bit of Twilio. Job's a good'un.

For the record "sprinkle some AI on it" is if statements, it was a yoke.

Re:GNU poke 1.0 by wizzwizz4 on Friday February 26, 2021 @02:41PM (#26278950)
Have it specified in a config file, and provide presets for common configurations (e.g. last line and exit code in SMS but full log in email).
Re:GNU poke 1.0 by wiml on Friday February 26, 2021 @01:58PM (#26278393)
It's not exactly what you describe, but you might find some use in the pv (pipe viewer) command: http://www.ivarch.com/programs/pv.shtml
Re:GNU poke 1.0 by jonathankoren on Friday February 26, 2021 @02:49PM (#26279053)