News for hackers. Stuff that matters.
Re:Fish: A user-friendly command line shell for macOS, Linux... by techdragon on Tuesday December 12, 2017 @09:37PM (#15911598)
I see that https://github.com/fish-shell/fish-shell/issues/3341 is scheduled for 3.0. This is also marked as the fix for the broken/invalid YAML format that is used for storing the shell history https://github.com/fish-shell/fish-shell/issues/2258

I implore you to NOT use JSON or ProtocolBuffers, neither are appropriate formats for configuring my shell, or storing long sets of textual data. Protocol Buffers is hardly the kind of format I want to parse and read my history in, and JSON is a less than ideal configuration format for many reasons.

https://github.com/vstakhov/libucl UCL (Universal Configuration Language) is a much more appropriate format for configuring programs than JSON, and is has been accepted as standard for use configuring all tools included in the FreeBSD operating system.

I also suggest you consider using a different language to store shell history, since shell history and shell configuration are two very different jobs with different goals and trade offs. I personally would suggest a simple safe format like TOML https://github.com/toml-lang/toml for storing the history.

But If you do want a single format for both configuration and history, I would implore you to pick TOML not JSON or Protocol Buffers.

Re:Fish: A user-friendly command line shell for macOS, Linux... by GlitchMr on Wednesday December 13, 2017 @01:55AM (#15912543)
Supporting this, I don't think protobuf is a good format for storing history files. Backward compatibility is tricky with it - I don't think the history format is going to change all that much, but I think there were changes in history of fish shell like adding time field. If the choice would be on a binary format, I would much, much, much more prefer SQLite for that. Also, B-trees are perfectly fine choice for searching history, as they make prefix searches trivial.

TOML is definitely an interesting choice if a text format is deemed necessary however. Array of tables syntax should be a fine syntax choice for storing history.

Re:Fish: A user-friendly command line shell for macOS, Linux... by FRex on Wednesday December 13, 2017 @03:06PM (#15917171)
I was about to say SQLite, it seems perfect - binary, fast, easy to update cheaply in place, immune to escaping et al problems (if you use prepared statements, not glue SQL with + of course), reliable, available in most languages (even for C and C++ the integration is trivial - it's a single pair of files drop in) and on the CLI, stable, the history data is very row/item oriented and not totally heterogeneous or free form, etc.

I totally drank the SQLite koolaid a long time ago.

Re:Fish: A user-friendly command line shell for macOS, Linux... by cben on Sunday December 17, 2017 @12:04PM (#15946525)
History file may be read & updated simultaneously my multiple processes. Is that sufficiently safe from corruption with SQLite? (honest question, no FUD implied. same risks apply to alternatives too.)
Re:Fish: A user-friendly command line shell for macOS, Linux... by timdierks on Sunday December 17, 2017 @05:09PM (#15947966)
Yes, SQLite has robust multiprocess locking and transaction support. https://sqlite.org/faq.html#q5
Re:Fish: A user-friendly command line shell for macOS, Linux... by fpoling on Wednesday December 13, 2017 @03:30AM (#15912890)
In addition protobuf is designed for communications, not incremental updates in a local store. As such making things robust to store things on a development machine is non-trivial. SQLite is so much better for that. After Firefox switched to use it for its own history, most problems with history corruption disappeared.
Re:Fish: A user-friendly command line shell for macOS, Linux... by theshrike79 on Thursday December 14, 2017 @11:15AM (#15923405)
You can ad extra fields to protobufs just fine, they just need to be added to the end of the definition.
Re:Fish: A user-friendly command line shell for macOS, Linux... by __sr__ on Tuesday December 12, 2017 @11:09PM (#15911955)
Out of the mainstream formats, JSON is among the easiest to parse - thanks to the CLI tool jq. Does UCL have something equivalent?

Protobuf (or any other binary format) has the benefit of being faster to load, but I agree - it should not be be used to store things like history. It should be easy to parse history without having to write code. And with Protobuf, you need the schema.

If a binary format is going to be used, it should be optional - or perhaps there should be tools to convert the history file to/from a plaintext format.

Re:Fish: A user-friendly command line shell for macOS, Linux... by techdragon on Wednesday December 13, 2017 @03:05AM (#15912785)
There is uclcmd [https://github.com/allanjude/uclcmd] which could do with some more work but was created with the intent of being a UCL equivalent of JQ.

Also since he’s the kind of person that a HN reader will probably Ike to know more about. The original author of the aforementioned uclcmd, Allan Jude [http://twitter.com/allanjude], is the former host of the TechSNAP podcast [http://www.jupiterbroadcasting.com/show/techsnap/], current host of the BSD Now podcast [http://www.jupiterbroadcasting.com/show/bsdnow/], a current member of the FreeBSD Core team, and co-authored not one but two books on the ZFS file system FreeBSD Mastery: ZFS [https://www.amazon.com/FreeBSD-Mastery-ZFS-7/dp/0692452354/] and FreeBSD Mastery: Advanced ZFS [https://www.amazon.com/FreeBSD-Mastery-Advanced-ZFS/dp/06926...]

Re:Fish: A user-friendly command line shell for macOS, Linux... by jhoechtl on Wednesday December 13, 2017 @01:30AM (#15912464)
Would like to see comments in configuration, Json doesn't support comments.
Re:Fish: A user-friendly command line shell for macOS, Linux... by nine_k on Wednesday December 13, 2017 @11:37AM (#15915296)
UCL can be trivially transformed to JSON or YAML; ucl-tool supports this from CLI.
Re:Fish: A user-friendly command line shell for macOS, Linux... by ridiculous_fish on Tuesday December 12, 2017 @10:10PM (#15911723)
Thanks for writing that up, I linked to it from the issue. FWIW I agree with you that shell history should be a simple format, and even ad-hoc parseable via Unix tools. zsh uses simple : and ; delimiters. JSON is more complex, and binary formats like protobuf are way out.
Re:Fish: A user-friendly command line shell for macOS, Linux... by Conan_Kudo on Wednesday December 13, 2017 @07:39AM (#15913835)
Long-time fish user here, I'll second this comment and implore that you choose TOML for the configuration format. TOML format is easy for users to understand, and well-written parsers for it exist in every programming language.
Re:Fish: A user-friendly command line shell for macOS, Linux... by fpoling on Wednesday December 13, 2017 @03:16AM (#15912836)
For configuration I would very much prefer to have something that can be properly grepped/patched/generated with shell scripts if necessary. What openssh uses for its config mostly fulfill this, but ini file also are not that bad. Anything hierarchical like JSON/TOML/UCL etc. becomes very unattractive the moment one has to patch them from automated setup scripts.
Re:Fish: A user-friendly command line shell for macOS, Linux... by webwurst on Wednesday December 13, 2017 @01:36PM (#15916294)
There pretty mighty tools around to grep/patch/generate JSON data with shell scripts and they are made to deal with hierarchical data.

https://stedolan.github.io/jq/manual/

http://jsonnet.org/

Both are single binaries, so easy to run them where you need it. I don't know comparable stuff for the other mentioned formats, whenever I need to deal with yaml in scripts i run

https://github.com/bronze1man/yaml2json

I would be totally fine with any format that can be converted to JSON on the fly. Of course I would love to have something like these tools more integrated within a shell, but the representing text format on the disk is not that important for me.

Re:Fish: A user-friendly command line shell for macOS, Linux... by merlincorey on Wednesday December 13, 2017 @03:48AM (#15912961)
Templates in configuration management can help with this a bit.
Re:Fish: A user-friendly command line shell for macOS, Linux... by daenney on Wednesday December 13, 2017 @10:19AM (#15914741)
Thanks for bringing up UCL! Hadn't seen that before but I definitely need to try this in a few places.