3 ms·
> somebody recently suggested that I add history to sqlite in Oil what a disgusting, perturbed mind! Shell history is probably the kind of data that fits bett
by enriquto 7y ago
> somebody recently suggested that I add history to sqlite in Oil
what a disgusting, perturbed mind! Shell history is probably the kind of data that fits better as a text file. It is naturally textual and it can never grow too long, even if you are typing commands continuously for your entire life. Please, keep the dirty hands of sql far, far away from the shell!
- stevekemp 7y agoI can almost see the appeal, when you think of decorating it. Consider a table with five columns: * uid * pwd * cmd * exit-code * datetime Now you can `SELECT pwd,cmd WHERE exit-code != 0` to see all failed-commands.
- enriquto 7y agoI see your "decorated" sql table, and I raise you my text file with five columns, that you can grep and sed and awk as if there was no tomorrow. cat history.txt | awk '$4 != 0'
- zepolen 7y ago"As if there was no tomorrow" - exactly, because once you add another column suddenly $4 points to something completely different and you have to rewrite everything. Not to mention $4 is completely arbitrary and it's impossible to tell without prior knowledge which field it's referencing. The original query `SELECT pwd, cmd WHERE exit-code != 0` is both descriptive and won't break with future updates.
- chubot 7y agoYeah I agree. In Oil I'm hoping to have the best of both worlds. That is, no silly quoting and parsing of strings, but also being able to use plain tools like "grep", and probably SQL. https://github.com/oilshell/oil/wiki/Structured-Data-in-Oil https://github.com/oilshell/oil/wiki/Structured-Data-in-Oil Note that R has some popular packages that allow SQL syntax over data frames. So basically the history file could be a textual table. You could trivially import it into a database, or you can just grep it.
- chubot 7y agoHa, thanks for the feedback... Yeah I don't want the sqlite dependency by default. The fact that somebody managed to bolt it onto bash after the fact is interesting. Oil is all about having a better/sane shell programming language, so it should have better hooks that make such customization. But yes it doesn't need to be in the core.