News for hackers. Stuff that matters.
Re:Show HN: Memorize Terminal Commands by jclulow on Sunday July 28, 2019 @09:18PM (#20550795)
I think to do this properly you need to implement the argument parsing the command is doing; e.g., use getopt(3C). After all, "ls -la -h --" is valid too.
Re:Show HN: Memorize Terminal Commands by TheDong on Monday July 29, 2019 @12:50AM (#20551597)
Not all unix utilities use getopt.

Clearly the correct way to implement this is to run each command in a short-lived container and check the output matches what's expected. For things like the pager questions, it'll need to implement a full vte and vte comparison, so that should be fun.

For bonus points, one of the options to emulate linux in the browser could be used to do that more securely and without the need for a service... though the load time might increase by several minutes or hours.

Re:Show HN: Memorize Terminal Commands by darrenf on Monday July 29, 2019 @02:35AM (#20551987)
> Clearly the correct way to implement this is to run each command in a short-lived container and check the output matches what's expected.

I'm not sure it is clearly correct. Some commands don't produce output, `mkdir` and `cd` for example (the first two in the animation). Furthermore they'd have to blacklist `echo` and other ways to produce the output against the spirit of the exercise... until an answer is, say, `echo $?` - at which point you'd require a preceding command exiting in a suitable way in order to keep the "just execute it" approach workable.

Re:Show HN: Memorize Terminal Commands by icebraining on Monday July 29, 2019 @08:19AM (#20553741)
> though the load time might increase by several minutes or hours.

Just a few seconds on my humble E480 using Firefox: https://bellard.org/jslinux/vm.html?url=https://bellard.org/...

Re:Show HN: Memorize Terminal Commands by mikorym on Monday July 29, 2019 @01:22AM (#20551710)
You can just put the flags in a set and test for set equality.