Daily Fix - Friday, April 11th 2008
I often need to grab older versions of libraries and applications, and I’ve encountered a recurring problem when I pull down an application packed as a self-extracting archive for Linux. These usually end in .bin and force you to accept some sort of agreement, then unpack themselves. I’ve seen this with older version of the Sun Java release (i.e. 1.4 and before) on Linux, but it occurs elsewhere. The problem is that the application script calls tail using an older syntax like this:
tail +305 …
which means print the file (or bytes or whatever) starting at line 305. That particular syntax isn’t supported anymore due to a standardization of the way arguments are passed in POSIX systems. See:
http://www.cygwin.com/ml/cygwin/2005-03/msg01112.html
So when the archive tries to unpack, it freaks out and you see some error about unsupported syntax for tail and you get nothing on the output. You can fix this by setting a magic environment variable called _POSIX2_VERSION. By default it is set to 200112, but if you change it to 199209, tail will be accept the old argument style. So to unpack those old archives, do:
> _POSIX2_VERSION=199209; export _POSIX2_VERSION
> ./the_previously_misbehaving_archive.bin
Since you only set the environment for the shell, quitting and reopening a new shell will clear this value. Also be careful that if you are unpacking the archive using sudo, this trick will fail since the environment variable doesn’t get passed through.