That Looks Somewhat Iffy

Oh, go on, then.

  % history 1 | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head
  320 git
  112 ll
  80 cd
  48 ls
  24 less
  20 man
  17 sudo
  15 rm
  14 xattr


  1. This is at home, not work. At work, there’s significantly more git, ant, mvn and mate.
  2. I turn all my ssh known_hosts entries into command line aliases, hence “”.
  3. I’ve only just found xattr, so I’ve been playing with it.
  4. zsh only lists 25 history items by default. I have to ask it to start from the beginning.
  5. I obviously do too much as root.

As always, I can’t resist tinkering with the shell. I’d have written it as history 1 | awk '{print $2}' | sort | uniq -c | sort -rn | head.


m2eclipse tip

I was wondering why one of my computers seemed to have an older version of m2eclipse installed. It turns out that they moved the update site from to Doh. It’d be nice if they mentioned that one the front page.


Nostalgia (not by Veidt)

I was thinking about what I needed to do tomorrow. One of the tasks involved writing a DOS batch file for a colleague. That got me thinking. When did I learn to write batch files? Scarily, I realised it was 20 years ago. I must have been 14 at the time. I had an Amstrad PC 1512 and I wanted to learn everything about it (and play Ultima V a lot).

So, I spent ages reading help, playing with commands to see what they did. I even managed to get a book or two (if the books seem expensive now, they’re even more to a 14 year old with practically no income).

Learning batch files was pretty much mandatory — you had to configure AUTOEXEC.BAT somehow. But learning why you needed to prefix “echo off” with an @ was fascinating[1].

Somehow this information has stayed relevant a lot longer than I thought it would. Certainly longer than the DOS assembly coding I did (a PSP was a Program Segment Prefix long before it was a Play Station Portable — but who cares these days?).

I had little realisation quite how bad batch files really were until I came across sh on SunOS 4 at University. The whole Unix thing (including the culture) was pretty mind-blowing.

I guess I’ve just officially joined the “old farts” club. 🙂

1 “echo off” stops outputting commands to the console. But the “echo off” itself has already been output to the console by that point. The @ in front stops that. Looking back now, it seems remarkably similar to the syntax used by make(1).


for() $DEITY’s sake, why?

I used to think I had a reasonable grasp of Perl. Yesterday, I realised I didn’t even understand a basic foreach loop.

  my $val;
  my @values = qw( a b c );
  foreach $val (@values) {
    print $val, "n";
  print "[end] $valn";

I reckoned that this should print:

  [end] c

Instead, it prints:

  Use of uninitialized value in concatenation (.) or string at line 11.

This confused me no end. But it’s actually documented behaviour. From perlsyn

The foreach loop iterates over a normal list value and sets the variable VAR to be each element of the list in turn. If the variable is preceded with the keyword my, then it is lexically scoped, and is therefore visible only within the loop. Otherwise, the variable is implicitly local to the loop and regains its former value upon exiting the loop. If the variable was previously declared with my, it uses that variable instead of the global one, but it’s still localized to the loop. This implicit localisation occurs only in a foreach loop.

Wow. You really do learn something new every day. I suspect that this is implementation behaviour that was documented post-fact, rather than designed that way.