A fix for the F3 /var/log bug...

Alfie Costa agcosta at gmx.net
Sun Jun 1 05:12:32 UTC 2003


On Thu, 29 May 2003 23:26, Oswald Buddenhagen wrote:

> > 	x=QuousqueTandemAbutere
> > 	echo ${x##Quousque}

> /bin/sh on solaris 8: bad substitution

Thank you, kind SunOS user.

> > In the meantime, for those who prefer the 'file -z' way, attached is
> > the same patch, changed so it does it the 'file -z | grep' way.

 > this solution is sort of ... stupid ... :]

Sort of, but I think mine would work "out of the box", or on install... 
excepting those peculiar man pages that 'file' misidentifies.  And it 
should work for all distros, albeit inefficiently.

 > as mc does not automatically call file -z (or uncompresses the file
 > itself), i created the wrapper /usr/local/bin/file:

 > ----------------------------
 > #! /bin/sh
 > /usr/bin/file -z "$@"
 > echo "Warning: -z switch implicitly used"
 > ----------------------------

This works for you, but how to package it?  Suppose a user already has a 
special /usr/local/bin/file -- then the 'mc' install script, (I think 
that's how Debian does it...), would have to allow for that.  (And so on 
for how all the other distros do it.)  Or suppose the '-z' bolixes up 
some other script that calls 'file'.  Maybe the .deb that installs 
'file' would need to know about the wrapper too.

That is, a wrapper script for 'file' may be even less portable than '##'.

 > type/^(ASCII )?troff.*gzip compressed

Ohhhh.  Well, I didn't understand the what the 'type' keyword was for. 
      Thanks again...

As applied to my last 'file -z | grep' patch, using 'type' would at 
least allow replacing the uncompressed man page logic with 'type/^(ASCII 
)?troff', which is a partial improvement.  (The redundant compressed man 
page logic I'd leave be, rather than use an unportable 'file' wrapper, 
though.)

How does this sound:  somewhere in the 'mc' source it calls 'file' -- 
can't we just change that so it calls 'file -z' as needed?  The logic 
would go like:

1) let x = `file foo`
2) is foo compressed?  Goto 4.
3) let x = `file -z foo`
4) return x

Assuming this didn't goof anything else in 'mc' -- don't see why it 
should -- then all your 'type' code would work without a wrapper script.







More information about the mc-devel mailing list