Search Results: "az"

1 February 2006

David Nusinow: Oh GNOES! SCM DISCUSSIONZ0R!!!!!!

After seeing everyone shill for their favorite scm lately, with most of the predictable ones getting the attention, I thought I'd throw my choice out there, just to see it represented.

I primarily use svn with my work on X in Debian, and it's a wonderful system. Fortunately though, I don't have to maintain the repos, and when something goes wrong I can cry to our beloved DPL to get his admin on, and he fixes things up. This works out fairly well for me as a basic user, but I don't want to be dealing with these sorts of hassles for smaller projects. The distributed scm thing appealed to me in this sense, so when arch started to become a serious buzzword in the Debian crowd I had a look.

Well, more than a look. I fought for over a month with tla and baz and found that they were both so unuseable and poorly documented that I couldn't do more than scream and cry. bzr looked cool, but it wasn't ready (I sorta tried to manage one of the X.Org releases in Debian with it and failed miserably). Darcs was slow and in a minority language, which was a major turnoff for me. And I don't have a ton of diskspace, so git was out. Svk struck me as a hack (it still does) so I didn't want to go with that. Monotone was ok, but not good enough, so I sighed, gave up, and went back to svn thinking that this was as good as it could get. Indeed, we added a quilt-based patch system to the Xorg packages, so now I have a mini-scm (quilt) inside an scm (svn) and it works amazingly well.

But one of my friends just got hired by the people who make Xen, and he mentioned that they used mercurial, and asked if I had tried it yet. I scoffed and said no, and that all scm's suck harder than anything has ever sucked before, but I had a lot of time to kill while I was waiting on an X build, so I gave it a look.

Mama, I'm home. I was stunned that I was able to pick up mercurial in about half an hour after tearing my hair out for over a month with arch.

The UI is apparently very darcs-like (by accident, according to the mercurial author) which is known to be fantastic. Branching, merging, etc is simple as can be so far, although upstream is still working out better methods to deal with merging.

It's very fast, built for large trees (i.e. the kernel) so it will be suitable for managing X with (although I haven't tried this yet, but I plan to). For X, I'll need something fast to keep my sanity. This rules out darcs and baz (which has somehow managed to get amazingly slow in addition to being difficult as of late).

Unlike git, it keeps changesets in xdelta format rather than storing whole files, so it doesn't eat my hard drive.

It's written in python, so it's something I could hack on if I want to.

It supports an easy server setup with apache, and you can push your repos and serve them via static http if you don't have a server, like me.

Like monotone, it exposes hashes to the user, but unlike monotone it also provides a local revision number to make sure you don't spend all your time copying and pasting hashes, which is what put me off from monotone.

It has a fairly small command set, with 39 commands in the current tip (i.e. HEAD) as opposed to the > 150 in baz which made me weep.

It feels like using bzr, except it's here now and ready for production. Indeed, it's already used in production in making Xen.

There's a bunch more that I won't talk about, mainly because these are the things that have grabbed me. A note of caution is that I've only been hacking on local projects by myself (mainly configure-debian) with it, so I don't have the tons of real world experience with multiple trees that the thing is built for yet. I'm thinking about putting up a parallel mercurial tree to the XSF tree just for fun (the svn repo would remain the canonical one) if people are interested and I can find a server. I hope though, that all the people out there who, like me, were bouncing around trying out scm after scm and never being quite happy with any of them at least give mercurial a fair chance. I'm still amazed at how much I like it, and I think some others might feel the same.

David Nusinow: X Strike Force Moving Forward

Today was a good day in Debian X land. X.Org released the "zeroth" release candidate for both the 6.9 (monolithic) and 7.0 (modular) versions of the X.Org tree. I downloaded the 6.9 tarball, imported it in to the XSF svn repo, and got to work on the patchlist. I'd already ported a number from 6.8, and tonight I managed to finish the rest. Except for a massive GNU/kFreeBSD patch, every single patch in the debian tree has been ported over to 6.9. This work took multiple weeks with multiple people for 6.8 using dbs. Using our new quilt-based patch system I blogged about in the past, this took me about half a week, with the bulk of the work over the past two nights.

Now I haven't actually been able to build 6.9rc0 yet, nor have I been able to build 6.8 for a few days. There's currently a bug in the linux-kernel-headers package that breaks the X.Org build, so the XSF has been working on polishing the -5 release. Eugene Konev has fixed things to we now build HTML docs for xspecs again, for those of you who hate the postscript versions. David Mart nez Moreno has been doing an enormous amount of cleanup, generally dealing with a lot of the bugs that have come in and taking care of the new translations that have been flooding in almost as fast as we can change the debconf templates :-) Christian Perrier has joined the team as translation coordinator, so as soon as he can get svn access the X packages should be well taken care of in his amazingly capable hands. Finally, I've included a new script for /etc/init.d supplied by Petter Reinholdtsen that will give Debian LiveCD-derivatives a standard way of generating an X server configuration on boot. Nothing too fancy, but we're tightening up the package a bit more and those fixes have already been merged in to the 6.9 branch.

So if people need updated drivers from Xorg's HEAD, keep an eye out for 6.9rc packages to hit experimental. As soon as I can build and test them, I'll put them there for people to play with. My goal is to get 6.9 in to unstable on the day it's released by upstream. We're (or at least, I'm) going to begin work on 7.0 as soon as 6.9 hits experimental as well, borrowing one more time from Ubuntu and attempting to stabilize that packaging alongside them, if they haven't already beaten us to it completely :-) So things are moving and we're going to try and keep up the momentum.

Some people have also been asking about xcompmgr/transset packages. It's still not packaged for Debian because it's either slow or crashy, depending on your driver, although fixes are in the works. I may have found someone to maintain it for Debian, and I'll try and keep people posted about it when I know more.

31 January 2006

Gunnar Wolf: Novel noble ideas for solving the world's problems

Yesterday, the right-wing PAN candidate for the presidency of Mexico, Felipe Calder n, made a declaration that shadows the current president, Vicente Fox (from his same political party) almost look like a genuine statesman. (some links, La Jornada, El Universal) - And that's no easy feat, given that Mr. Fox is -so far- the nation's most prolific president... When it comes to stupid sayings.
How come Calder n rose so quickly to become a statesman? Let me first go through a bit of history. Not much, promise. Well, I'll do my best.
Twelve years and one month ago, Mexicans woke up with the frightening news we had a violent guerrilla group in Chiapas, one of Mexico's richest states, but one with the highest percentages of poor people - and, not coincidentally, of indigenous population as well. This uprising was very soon known all over the world - And its leaders quickly learned how to ensure they would not be prosecuted and exterminated: Simultaneously with the fighting, they made as large a media coverage as they could, strongly supported in the Internet democratization of the information that had just begun. Thousands of people all over the world understood their ideas -at least what they said at that time- and spread the word. I had my first trip in Europe with my (now) wife in 1996, and we saw many grafittis stating Viva Chiapas, Viva EZLN... It was amazing.
EZLN was (is) specially hard for the government to kill. As they don't do military sabotages, terrorism or so on, it is very hard to justify military action. After 12 days of fighting, a truce was decreed. The truce was broken once, in the early years of the Zedillo government, but officially there is a cease-fire, observed by both sides. The Zapatistas have took the ideas and further promoted them, with action. My Chiapas-born friend Alex Ju rez often tells me about the tremendous cultural difference between the Zapatista territories and the paramilitary ones - In the Zapatista areas, you see indians reading books, working their land, organizing themselves in the Fair Government councils, and strongly opposing alcohol and drugs. Just the opposite from the other areas.
EZLN shifted their strategy some months ago, going beyond stating their wishes for a fair regime and waiting for the government to look at them. I still don't really understand where they are heading, but the Sixth Declaration of the Lacandon Rainforest turns them into a political movement, clearly separated from the existing regime. They do not seek to be elected, they oppose every party and candidate. They define themselves as an anticapitalist movement, located down and to the left - Lets see where this goes to.
Well, back on track... One of the president's most famous stupid quotes is that, during his campaign, he promised to solve the Chiapas conflict in fifteen minutes. Well, it's been either fifteen very long minutes, or he just hasn't had any time to devote to those dirty indians. Mexicans are very frustrated by the lack of importance this man gave to one of our country's longest and most desperate needs.
Of course, Felipe Calder n must do something in this regard. Fox's shadow is a big one, and this little man must try to escape from Fox's biggest mistakes. So he just came with a formula that I don't know why no statesman thought of before: Instead of negotiating, instead of working to solve a very difficult problem, he declared he will unilaterally declare peace with EZLN.
I wonder if this year's Nobel prize will go to such an abnegated, smart and selfless person. Man, we could take this same solution to Darfur, to Israel/Palestine, to Congo, to Chechnya... If rulers all over the world start declaring peace unilaterally, all of the world's problems will be solved! What comes next, he will declare (maybe as Salinas did) that we are a first world country? Poor people are only sad reflections in the sand but don't exist in his reality?
Please, Mexicans: The man is clearly schizoid. Are you happy with Foxilandia? It seems that alternate realities are part of the PAN's action program. If you are not satisfied with Fox's results (who is?), don't vote for this guy. We will all regret it.

Zak B. Elep: Itinerary for Feb: AsiaBusinessTour and BOSF

In a little while I’ll be packing my things: clothes (with a few formal attires), a couple of (C/data structures) books, some snacks (Nerds!) and spare change (no bills). I’ve yet to see all of them fit in my backpack, so I’ll probably bring a couple of bags. Tomorrow, I will be bound for Manila yet again, much earlier than usual, for the AsiaBusinessTour on Thursday. And on the 16th, there will be the Bicol Open Source Forum in Legazpi City. Joseph Davidton Cadag invited me to be a speaker; I’ve yet to accept, but I’m leaning to it, especially since this would be a great opportunity to speak more about FOSS to my fellow Bikolanos. Also, its a nice time to meet up with Irvin Piraman who will be giving some Ubuntu CDs in the Forum too. I just hope I can finish my (re)packaging of ecb which I ITA‘d since last August. There is a package of the new upstream version already, but there seems to be a lack of Debian sponsors who can look into Emacs-related packages. sigh

Christine Spang: Books, books

I finally got out to Barnes and Noble today to spend the last of my Christmas/birthday gift certificates. Bought the last two books in Robin Hobb’s Farseer Trilogy as I have the first book but haven’t read it yet, as well as the third book in Robert Jordan’s Wheel of Time series. Incidentally, I was told by a friend that it’s only worth reading the first three books of the Wheel of Time, as it goes on forever and ever with little development. Please correct me if I’m wrong. I was tempted to buy The Atlas of Middle-earth but was swayed by my OCD at having unfinishes series (what on earth is the plural of that word? serieses? I want to say it doesn’t change, but that sounds funny) in my bookshelf. I’m still not sure when I’m actually going to read all these books, but, uh, I’ll figure that out eventually.

30 January 2006

Martin F. Krafft: Justin Hall

If you've been on the web for long, you will know Justin Hall and his infamous links.net. I know Justin from college and I've always respected him for the freak that he is -- which is not supposed to sound derogatory in any way. I've often envied him for what he was capable of. ... and we lost contact a while ago. So much that I didn't even take note of his breakdown. If it had been anyone else publishing this movie online, I'd have hit 'q' about 10 seconds in. As it stands, seeing it really had an impact on me. I don't know how, time will tell, but I feel it. Dropping him a note now.

Jordi Mallach: Going to FOSDEM 2006

After several years of chickening out in the very last moment, I finally booked plane tickets to Brussels for this year's FOSDEM. azeem, you can stop calling me names now. :)

Ross Burton: Sound Juicer "J'd Up To The Boom" 2.13.4

Sound Juicer "J'd Up To The Boom" 2.13.4 is out. Tarballs are available on burtonini.com, or from the GNOME FTP servers. Bug fixes: Translators: Adam Weinberger (en_CA), Ales Nyakhaychyk (be), Ankit Patel (gu), Clytie Siddall (vi), Evandro Fernandes Giovanini (pt_BR), Francisco Javier F. Serrador (es), Funda Wang (zh_CN), Gabor Kelemen (hu), Ignacio Casal Quinteiro (gl), Ilkka Tuohela (fi), Jean-Michel Ardantz (fr), Kjartan Maraas (nb, no), Lasse Bang Mikkelsen (da), Theppitak Karoonboonyanan (th), Tino Meinen (nl). NP: Gorillaz, Gorillaz

Antti-Juhani Kaijanaho: Counting lines

Insipired by Daniel Burrows’ tests, I decided to do mine. The object is to come up with a Haskell program that performs the job of wc -l as efficiently as possible. My test material is a randomly generated file with all lines less than 80 characters long. Summary: my final idiomatic version is twice as slow as wc -l, and my final nonidiomatic version is as fast as wc -l, or at least within the margin of error. First, the baseline:
$ time wc -l testfile
7798137 testfile
real    0m12.127s
user    0m0.765s
sys     0m0.399s
Then the most idiomatic program. Honestly, I expect it to suck performance-wise:
main = getContents >>= print . length . lines
And it does:
$ time ./wcl1.hs < testfile
7798137
real    1m14.993s
user    0m54.182s
sys     0m0.573s
But only by a factor of six. My first hypothesis is that garbage collection is the culprit. And, indeed:
$ time ./wcl1.hs +RTS -sstderr -RTS < testfile
./wcl1.hs +RTS -sstderr
7798137
25,236,174,340 bytes allocated in the heap
5,070,193,924 bytes copied during GC
117,484 bytes maximum residency (3750 sample(s))
96274 collections in generation 0 ( 26.36s)
3750 collections in generation 1 (  0.74s)
2 Mb total memory in use
INIT  time    0.00s  (  0.00s elapsed)
MUT   time   27.17s  ( 42.72s elapsed)
GC    time   27.10s  ( 33.72s elapsed)
EXIT  time    0.00s  (  0.00s elapsed)
Total time   54.27s  ( 76.44s elapsed)
%GC time      49.9%  (44.1% elapsed)
Alloc rate    928,824,966 bytes per MUT second
Productivity  50.1% of total user, 35.5% of total elapsed
real    1m16.616s
user    0m54.278s
sys     0m0.700s
As you can see, GC takes half of the processing time. Unfortunately, minimizing GC time does not have as big an effect as I hoped:
$ time ./wcl1.hs +RTS -H100M  -RTS  < testfile
7798137
real    1m1.354s
user    0m44.371s
sys     0m1.171s
Here, I’m effectively telling it to use a 100-megabyte heap. A separate GC profiling run tells me that GC time has dropped from 50 % to 1 %. The memory problem seems to be a red herring. What we’re doing here is creating four separately allocated memory cells for each character in the input. Of course, the cells are generated lazily, that is, a cell pair is allocated when the lines function demands another character; it then creates another cell pair to denote the same character in a list of lines. As soon as each line has been counted, the four cells become garbage. This sounds like a lot of work! But apparently it isn’t; I tried a few variations that did away with the stream of input altogether, not much unlike what Daniel did in his tests. Surprisingly, the performance worsened a lot. The lesson: functional programming language implementations, unlike typical imperative ones, are built on the assumption that you’ll be doing a lot of allocation. What I suspect is taking a lot of the time is arithmetic. Haskell’s Int is boxed, and lazy by default, adding a lot of overhead. I hand-fused length and line, yielding a tail-recursive countLines function, and I added the command-line switch -funbox-strict-fields, which enables a few significant optimizations of the laziness of Int. The results were nice:
ajk@kukkamaljakko:~/scratch$ cat wcl4.hs
module Main (main) where
main :: IO ()
main = getContents >>= print . countLines 0
countLines :: Int -> String -> Int
countLines n ('n':r) = countLines (n + 1) r
countLines n (_:r) = countLines n r
countLines n [] = n
ajk@kukkamaljakko:~/scratch$ ghc -O -Wall -funbox-strict-fields --make wcl4.hs -o wcl4
Chasing modules from: wcl4.hs
Compiling Main             ( wcl4.hs, wcl4.o )
Linking ...
ajk@kukkamaljakko:~/scratch$ time ./wcl4 < testfile
7798137
real    0m37.961s
user    0m29.853s
sys     0m0.495s
ajk@kukkamaljakko:~/scratch$ time ./wcl4 +RTS -H100M < testfile
7798137
real    0m25.153s
user    0m13.497s
sys     0m0.803s
ajk@kukkamaljakko:~/scratch$
With a large heap, the program is only twice as slow as the baseline. This is pretty good, considering that the code is still idiomatically functional. The following rather ugly, imperative program does away with the lazy stream and carefully avoids any laziness without doing any too dirty tricks:
ajk@kukkamaljakko:~/scratch$ cat wcl7.hs
module Main (main) where
import Data.Word
import Data.Array.IO
import IO (stdin)
count :: Int -> (Int, Int) -> IOUArray Int Word8 -> IO Int
count 0 _ _   False = undefined -- force ac evaluation
count ac (l,u) _   l > u = return ac
count ac (l,u) ar
    = do a < - readArray ar l
         let ac' = case a of 10 -> ac + 1
                             _  -> ac
         count ac’ (l+1, u) ar
maxn :: Int
maxn = 4096
main :: IO ()
main = do
  arr < - newArray (0,maxn) 0
  let loop :: Int -> IO Int
      loop acc = do n < - hGetArray stdin arr maxn
                    if n == 0
                       then return acc
                       else do acc' <- count acc (0,n) arr
                               loop acc'
  res <- loop 0
  print res
ajk@kukkamaljakko:~/scratch$ ghc -O  -Wall -funbox-strict-fields --make wcl7.hs -o wcl7
Chasing modules from: wcl7.hs
Compiling Main             ( wcl7.hs, wcl7.o )
Linking ...
ajk@kukkamaljakko:~/scratch$ time ./wcl7 < testfile
7798137
real    0m13.431s
user    0m10.342s
sys     0m0.467s
Of course, this program is not Haskell 98, but the nonstandard things it uses are fairly common. As can be seen, this version’s performance is, considering the margin of error, equal to the baseline. The compiler used in this test is The Glorious Glasgow Haskell Compilation System, version 6.4.1, as packaged in Debian sid.

Ross Burton: Blog Comments

This morning before work I hacked up a few Pyblosxom plugins to do word blacklisting and a basic Turing test on comment posters. The blacklist currently only contains 'phentermine', 'poker', 'xanax', and 'viagra', but that should filter out 90% of the comment spam. For the rest, the Turing test asks the poster to add together two small numbers. The lazy bit is that these numbers are hard-coded at the moment, I'll add that later... Hopefully I haven't broken something and if people pass these tests then comments actually work, if not the please email me. I'll release the plugins later this week when I've added documentation and ensured they work. NP: In Between Dreams, Jack Johnson

Daniel Burrows: How much speed are you willing to give up for pretty code?

After experimenting a bit with Haskell and using it for some toy projects, I decided to see if there was any chance it could be used for a non-toy task; i.e., one where it might one day be necessary to actually have fast code. As a proxy for this, I decided to try a very simple task: counting the number of lines in a file. As input, I generated a file with a million lines of random data and an average of 40 bytes per line; all the Haskell programs were compiled with the current GHC in Debian unstable and with optimizations enabled.

The baseline is, of course, our friend "wc":

real    0m0.084s
user 0m0.043s
sys 0m0.040s


(this and all other timing data was taken after "cat /tmp/testwc.txt > /dev/null" to ensure that the file was cached) Now, it's probably too much to hope that a Haskell program will run as fast as a C program does, since the C program can run in a tight loop. But it seems reasonable that it should be possible for Haskell to be competitive with the trivial Python implementation of this program -- after all, Python is interpreted and Haskell is compiled.

import sys
n = 0
for line in sys.stdin:
n += 1
print n


Running this simple Python program under "time" produces the following statistics, a bit less than 10 times slower than the C version:

real    0m0.698s
user 0m0.643s
sys 0m0.050s


The trivial Haskell program to count the lines of its input is:

main = do c <- getContents ; print $ length $ lines c


Note that this is basically identical to the Python program, but expressed in a functional style. Pretty, but how does it stack up?

real    0m6.744s
user 0m6.426s
sys 0m0.213s


OW! Ten times slower than the Python code, and a good 80 times faster than "wc"! The gap can be lowered to "only" 50 times with the following program --

do c <- getContents; print $ length $ elemIndices '\n' c


-- but surely it's possible to do better. I'd expect that the expense here is in the use of lazy streams for IO; eliminating them gives us the following code:

wc :: Handle -> IO Int
wc h = do a <- mallocArray bufSize :: IO (Ptr Word8)
loop a 0
where loop a n = do amt <- hGetBuf h a bufSize
elts <- peekArray amt a
(if amt == 0
then return n
else loop a $! n + nlCount elts)


At this point, we're basically using Haskell as a (bad) imperative language. This function allocates a buffer, repeatedly reads into it, and counts the number of newlines in the buffer (I dropped some auxillary code to keep the post short). The $! is important; without it, even though this routine is tail-recursive, Haskell will still allocate an unbounded amount of memory to store the return value. (because, of course, it's terribly important to remember that you're actually returning "1+2+3", not "6")

So, how does this unreadable, hand-optimized version of the code perform?

real    0m1.980s
user 0m1.757s
sys 0m0.094s


That's right -- I've eliminated most uses of higher-level functional techniques, and the Haskell version is still two times slower than an ultra-high-level interpreted language, while also being uglier and harder to read! Ouch. It appears the old performance albatross of functional languages is not quite dead yet.

29 January 2006

Jonathan McDowell: I'm becoming a wedding bore

Kathy and I went out for dinner last night at Tootsies with Becca, Dave, Eli, J, Kaz and Will. It was a good night (even if the girls beat us at Cranium), but I found myself having to stop talking about weddings - I could see J and Kaz starting to glaze over early in the evening. This a frightening event. Is this how people become baby bores? Anyway. Kathy and I managed to look at a couple of potential venues yesterday and have another one arranged for next Sunday, and a few more to ring this week to hopefully see next weekend. It's all still very scary.

Eric Dorland: Goodbye Soekris, Hello Linksys

So I've replaced my Soekris 4501 with a Linksys WRT54G (version 4). I was running OpenBSD off a flash card on it. I was using OpenBSD because i really like pf. ntefilter is fine, but I really appreciate pf's configuration file grammar (always thought it was crappy that iptables doesn't have a configuration file). And OpenBSD's security track record gives me the warm fuzzies.

The romance is over though. The the Mini-PCI 802.11b card I had inside it has never worked quite right, the bandwidth has always been wonky. More recently, it doesn't seem to handle multiple high bandwidth operations gracefully (maybe since upgrading to 3.7). So I'm running OpenWRT on this WRT54G, and it's fairly slick. It's amazing how much functionality can be packed onto 4MB of flash.

Dirk Eddelbuettel: BHL, as reviewed by the NY Times

Having lived in France for a few years in the early nineties, it was hard not to notice BHL. Also called Bernhard-Henry L vy. In France, if you are somebody, you get called by your initials. BHL, the philosopher turned into a media-savvy writer and journalist was just about everywhere. Even I ended buying one of his tomes. [For those unaware of the cult of BHL, compare the very lengthy and admiring French Wikipedia article with the disclaimer-sporting short and sceptical English counterpart, or even, for completeness, the barely existing German one.] Well, fast-forward a dozen years and who marches onto Jon Stewart's stage at the Daily Show this Wednesday: Bingo, BHL himself. In the usual uniform: suit, spotless white shirt, perfect hair, though less of it than in the days. In rather passable English he gets to plug his new book on travelling the States. Of course, it's tough to be French and to write about the US as de Tocqueville is the inevitable comparison... So tough that the comparison has to turn into a take-down somewhere. Today's NY Times has a review of said book that is so highly entertaining that I cannot help but recommend it most highly, even if you never heard of BHL before. If the Times is this vitriolic, I can't even begin to imagine what a review in the WSJ would do to the poor man...

26 January 2006

Michael Janssen: Switching.

Last weekend I moved all of my websites from my expensive dedicated server solution to a shared server solution. So far everything has been working out great - the transfer of files went fine, and some of the automatic services that are setup for you, such as automatic secure webmail which is always nice to fall back on when you're at say, a public kiosk or something. The switch saves me approx. US$720 a year, which is going to be great for my finances. However, I'm always wary when I move to a new place that something is going to be horribly wrong, so it's watch-like-a-hawk time. One of the consequences of moving to the new server is using IMAP for reading mail. I am amazed, shocked and appalled that I didn't discover this earlier, but mutt has a caching mechanism, which increases the joy of reading both large Maildir mailboxes and IMAP mailboxes. To enable, just put set header_cache="/path/to/some/directory" in your .muttrc file - things go 10x faster after the first cache. In the same spirit of switching for a new year, I decided to switch my finances up a little bit. I'm currently migrating to using the StackBacks system for managing finances. This is the budget for the generation of consumers who would rather carry around a debit card than a bunch of cash, and is especially good for weaning yourself from credit cards. At the same time, I'm switching banks from a national chain to a local credit union.

David Pashley: Bad Shell: Lazyweb replies

Yesterday I posted about some bad shell code I had found and posted an improved version. Part of the reason for posting it was that I hoping someone could point out any errors in the version I posted. Fortunately Neil Moore emailed me some improvements.
  1. If the script returns more than one line they will be removed by the $(...) expansion when it is split into words. The solution there is to surround it in double quotes.
  2. The next problem Neil pointed out was that $@ should be surrounded by quotes in pretty much every case, otherwise parameters with spaces in will get split into separate parameters.
  3. The final problem is that if the script includes a return statement, it will stop the inner most function or sourced script, but not during eval.The solution is to enclose it in a function:
    
    dummy()   eval "$(perl "$CONF_DIR/project.pl" "$@")";   dummy "$@"
    
    
Since making the post, I discovered that Solaris' /bin/sh doesn't like $(...), so it's probably better to use backticks instead if you want to be portable. As I know the output from the script I'm not worried about return statements, so I've ended up with:

eval " perl "$CONF_DIR/project.pl" "$@" "

John Goerzen: The Mozart Quiz

Check out The Mozart Quiz over at the BBC. They play 10 music clips, and you have to choose from among the 3 composers listed. I got only 8 out of 10 correct. Sigh.

25 January 2006

Matthew Palmer: LCA 2006 -- The Early Years

So, I've arrived at LCA (linux.conf.au) 2006, in Dunedin, New Zealand. You're going to be getting a lot of these blog posts over the next few days, from me and other people, but it's only a week-long conference, so weather the storm. Plane trip over was... well, it was a plane trip. I can be thankful that I didn't lose my luggage (as one bloke has already had done to him). Beyond that, all aircraft interiors are identical, so no need to discuss that. At the stopover in Christchurch, we all headed for the bar (as geeks tend to do). I handed over a brightly coloured note in the local currency in exchange for my beer, and I get my change. What is part of my change? An Australian 10c piece. <sigh> Mad props to the conference organisers so far -- one of the organisers was at the gate (the only gate) at Dunedin airport to pick up speakers, but he gladly took us ruffian attendees into town, saving us all a few bucks in shuttle bus fairs. It was a nice guided tour in, as well, showing us all of the useful sights (like the pubs, 24 hour minimart, and eateries). He also dropped us off at the registration desk, so I got my conference schwag already (see my separate review of the schwag). Dinner involved walking into the octagon (a loop street with, unsurprisingly, 8 sides) and finding a place that serves you raw steak and a hot rock. It's like a portable BBQ construction kit. Amazingly tasty. We're going back tomorrow night for more of the same, as it's so tasty and fun -- you are legitimately allowed, even encouraged to play with your food. I also got a "barmate" (don't mispronounce that in front of your significant other) -- a yard-high glass cylinder with a tap at the bottom, filled with your choice of beer. Much merriment ensued amongst the assembled geeks, as we all plied ourselves with Speight's Gold Ale. I think it's about 8-10 pints worth of beer all up. Value. No Internet access yet, as they're still working out the kinks with the special conference network. I hope it's all up and running by tomorrow morning -- my mail queue is starting to seriously bulge with all of this outgoing mail.

David Pashley: Bad Shell Scripts

I'm always amazed at the number of bad shell scripts I keep coming across. Take this snippet for example:
TEMP1= mktemp /tmp/tempenv.XXXXXX    exit 1
perl $CONF_DIR/project.pl $@ > $TEMP1
if [ $? != 0 ]; then
  return
fi
. $TEMP1
rm -f $TEMP1
There are several things wrong with this. First it uses a temporay file. Secondly it uses more processes than are required and thirdly it doesn't clean up after itself properly. If perl failed, the temp file would still be created, but not deleted. The last problem can be solved with some suitable uses of trap:
TEMP1= mktemp /tmp/tempenv.XXXXXX    exit 1
trap "rm -f $TEMP" INT TERM EXIT
perl $CONF_DIR/project.pl $@ > $TEMP1
if [ $? != 0 ]; then
  return
fi
. $TEMP1
rm -f $TEMP1
trap - INT TERM EXIT
Of course this can all be replaced with a single line:
eval $(perl $CONF_DIR/project.pl $@)

Andrew Pollock: [tech] Asterisk and Engin, continued

So, given my earlier musings, I went ahead and signed up for the $10 a month Engin account (man it's hard to suppress adding an "e" on the end every time I type "Engin"). They finally approved the account today (took about a week or so I think), and I have a Brisbane telephone number. I've also bought the O'Reilly Asterisk book (yes, I've also downloaded the PDF for free, but I feel I should support the author, and I like reading books in dead-tree format). My next challenge is to obtain a couple of entry-level SIP handsets (recommendations welcome) and to actually get Asterisk up and running, talking to Engin. The pi ce de r sistance will be to get a TDM card with a couple of FXO modules to plug the standard POTS line and the output of the Vonage ATA (unfortunately Vonage doesn't appear to play well with Asterisk, so I'll have to do this crazy conversion) and have everything terminating in Asterisk. Of course this is up there with the MythTV box I never got around to building back home, but at least Asterisk is packaged for Debian, so all I have to do is get the handsets and configure Asterisk appropriately. Oh, and maybe actually stay at home for a couple of weekends.

Next.

Previous.