Archive

Archive for November, 2009

Git Submodules

November 22nd, 2009 subogero Comments off

The scariest free open-source tool of all – Git – proved to be one of the best. Again.

It is scary. I grew up on MKS, with a nice GUI, a central repository and files locked for editing. With git all that is blown out of the window. Instead, you get cryptic commands (git bisect bad, anyone?), a separate repo for everybody, branches and merges.

After the initial shock, which may have lasted a few months I must admit, I begin to see MKS Source Integrity as a broken tool. Nice GUI? It crashes after a few hours, anyway. Central repo? Why can’t I work off-line? And why shall I wait ages until someone breaks his lock for me? And it takes only one “git commit -a” to realise that those Check-ins, Update-Members and Checkpoints may be a bit over the top.

My most recent discovery in Git was submodules. It’s for reusing code. I realised that I had implemented the -h/-V switches (for help and version display) in multiple projects separately. That’s a cardinal sin, while constructive laziness is the cardinal virtue.

So I created a project called arg1 with a single module with a single function, which takes your program’s argv[1] as an argument, checks whether it’s -h or -V and prints the usage or version text respectively if it is, and exits.

void arg1Eval(const char* arg1);

The texts shall be stored as simple text-files (usage.txt and version.txt) in the reusing superproject’s up-dir. The arg1 project contains a makefile as well, which turns these txt files into .h files with a string initializer-list. It’s made by a tricky sed command:

%.h: ../%.txt
 @sed -e 's/[ \t]*$$//g' -e 's/^/"/g' -e 's/$$/\\n",/g' <$< >$@

To reuse this little thing in your project simply type

git submodule add ~/Projects/arg1 arg1

Now comes the best part: Instead of reusing something from your filesystem (~/Projects/arg1) you can use any URL. You can reuse the whole internet. You can even develop that submodule from within your main project.

My new MKS vs Git page explains a lot of submodule related functionality.

Categories: Uncategorized Tags: , ,

Interpreter Scripts

November 9th, 2009 subogero Comments off

I wanted to turn the ogc calculator into a full-blown interpreter, to be able to create an executable ogc test-script:

#!/usr/bin/ogc
# Test script for ogc.
# Invoke: "ogc Test" or simply "./Test"
# It shall produce the following output:
# 42
# 42
# 42

# 42 hex
11*3*2 x

# 42 oct
 F*2+4 o # Leading space

# 42 dec
 52 d # Leading tab

 # Leading tab and comment

This is called an executable interpreter script, starting with the Shebang line, which tells the kernel which binary program shall run the script.

Unfortunately it did not produce any output, ogc just started waiting for user input in its particularly silly way. What was wrong? I had to find out more about how interpreter scripts and shebangs work in Unix. It turned out the kernel passes the filename of the interpreter scipt as an argument to the interpreter. Upon executing Test, the kernel actually does this:

/usr/bin/ogc Test

Should have thought. A simple stdin-stdout filter is not enough, the interpreter itself shall be able to redirect its input into a specified file.

I modified ogc, so 3.0 can be used in both ways:

ogc Test
./Test

And to make it even more elegant, ogc 3.1 skips printing an output for whitespace/comment-only lines, including the shebang. The test script now does only what it really should: stressing 3 times what Life, Universe and Everything is all about.

Categories: Uncategorized Tags: ,

Why Karmic Koala Sucks

November 3rd, 2009 subogero 7 comments

I’ve just upgraded to ubuntu 9.10 Karmic Koala. I should not have.

1. Login

The Login Screen is ugly. It displays the computer’s users. There is no way to change it. And nothing else, for that matter. And it is booting SLOWER than Jaunty by 9 seconds.

2. Gnome

Everything seems to be slower. My customized desktop theme fell apart.

3. Firefox

No Hungarian spell-check dictionary available for Firefox 3.5.
And the too-tiny-font problem is still here.

4. Thunderbird

It became slow and unstable. It’s on the verge of being unusable.

5. Gnome-terminal

My customized xterm size was overwritten to the ridiculous 80×24 during the upgrade. Config Wizardry again.

6. Gnometris (Tetris)

The biggest disaster: it is completely broken!

I know. I’m an evil and rude bastard. I should not criticize people who kindly develop software in their spare time. But you have been warned:

If you’ve got Jaunty, do not, by any means, upgrade to Karmic.

Actually, I wanted to rearrange my partitions anyway. Where did I put that Jaunty CD?

Categories: Uncategorized Tags: ,