Login
Fossil bash scripts
Login

Home sweet fossilhome

This is a collection point for the bash scripts I use to fetch and run fossil servers. I've also included the source document fossil.org that I generate the scripts from. Technically, I could just deliver this single document, but then people without some org client wouldn't be able to extract the content readily. So I delivered the shell scripts as well.

Literate programming

The org-mode source document makes use of a concept called Literate Programming, which I think was first made known when Donald Knuth described it in his The Art of Computer Programming series of books. The concept involves writing sections of code wrapped in sections of descriptive text in an interleaved fashion. If we "tangle" the document, we get all the source blocks emitted. If we "weave" the document instead, we get all the descriptive text, in this case, with the source code picked out in their own display blocks. The basis behind it was the idea that you kept everything together, and hopefully your documentation would keep pace along with the source code because you'd be right there at the code. It would also give you a breakdown of further explanations around perhaps tricky-to-understand portions of the code, and perhaps the reasoning behind the code.

I haven't seen a lot of support for this idea in other editors, as most people tend to think of editing source and editing documentation as two distinct phases, that are usually artificially separated, without always making sure that the two are caught up on a consistent basis. This is especially true of big development IDEs such as Visual Studio that may have documentation support built in, but again, as a separate phase from working with the source code documents.

Anyhow, when you import the source document into an org-mode-capable editor (for example, emacs with org-mode) you can then tangle the document to extract the separate source files, as described down further.

Shell scripts

fossilsource

Link: fossilsource

This is the main script I created initially (fossilsource.sh, since renamed) and is a script to fetch all the respective fossil repositories of the fossil and sqlite projects that I know about. This list grew over time, partly as I discovered new subsections of code and partly as I discovered new servers, fnc and fsl being two good examples.

Running fossilsource help should give you all the gory details. Note that this differs slightly from the Linux norm of fossilsource -h, though that is also supported. You will need to edit the script to put the correct root directory if you put your fossils in a different place from me. This script doesn't fetch the fossils if you haven't already cloned them, it just does a sync/pull.

Hm, now there's an idea I hadn't thought of.

fossilserve

Link: fossilserve

This script (which still exists in an earlier embryonic form ) starts up a "master" fossil server which then lists all the remaining fossil repository files I have registered on my local computer. Originally I spawned each repo on its own port, but then I found it was far better to let fossil be the meta-server on one port instead of hogging a whole range of ports. After all, I'm only usually interacting with one page at a time, even if I have them all loaded into multiple tabs of a web browser. As you can see, it also makes the script a whole lot shorter, but it does depend on you having some fossils already set up on your system, or this won't work as the fossil binary will check what's in ${HOME}/.fossil to see what you have. This is easily solvable with a fetch of all the relevant fossils you want, then running up this script.

Building scripts

Huh? They're bash scripts. You just run them. However, if you want to rebuild them from the source document, then you'll generally need a setup like I have here - an emacs client with org-mode loaded with a couple of extensions - org-auto-tangle in particular. You can still build the document and extract the source files without org-auto-tangle, but you'll need to manually tangle the scripts each time you change the master document.

Future directions

Where to from here? I'm not sure, I guess I'll just nip-tuck as I see fit, perhaps making these scripts a little more generic as I go so that it doesn't matter who runs them, they won't automatically go to the place I use here. I guess this set of scripts is fairly feature-complete, and they're already in daily use here as part of my scratch-an-itch collection. You guys know what I mean.


Archaic remnants


Remnants of the original scripts—usually with a .sh suffix—still exist in the repository, although you may have to go back in the history to find some of them. But I've left a couple around as snapshots at the time I was working with them. You can see how I've progressed since then. One of these files happens to be from a time when I created a man-page-like page for fossil script, which would have been the "weave" phase of document building.