TOPIC: SINGLE UNIX SPECIFICATION
A UNIX shell running on Windows
15th November 2007Here's an idea that I got for a post before I spent that torrid weekend with Windows that caused me to jump ship to Linux. The idea of having a UNIX command line while still remaining on Windows did appeal to me at the time, and Cygwin seems to provide an intriguing way to do this. At its most basic, it is a set of DLL's that allow you to run standard UNIX commands in a shell like what you see below. However, it is extensible with a good number of packages that you can choose to install. NEdit is just one that gets included, and I think that I spied Apache too. The standard installation is a web-based affair, with your downloading only the components that you need; it's worth trawling through the possibilities while you're at it.
Now that I am firmly ensconced in the world of Linux, this may be one possibility that I will park, for a while anyway. After all, I now do have the full power of the UNIX command line...
Octals in UNIX shell scripting
9th February 2007I have just discovered that if you have a number with a leading zero, such as 08
, it is assumed to be an octal number, that is, one of base 8. The upshot of this is that you get errors when you have numbers like 08
and 09
in your arithmetical expressions; they are illegal in octal: 08
should be 10
and 09
should be 11
. Of course, as luck would have it, you get exactly these expressions when date/time processing. Luckily, you can force things to be base 10 by having something like 10#08
or, when extracting the minute from a date-time value, 10#$(date +%M)
. Strange as it might appear, this behaviour is all by design. It is dictated in the POSIX standard that governs UNIX. That said, I'd rather it if 08 was interpreted as an 8 and 09 as a 9 rather than triggering the errors that we see, but that could have been seen as muddying the simplicity of the standard.