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

On Thu, 29 May 2003 11:31, Oswald Buddenhagen wrote:

> yep. it's [ double hashes ] a bash-ism (or a ksh-ism, fwiw). 

It came from from Korn, but it's POSIX shell syntax now.

> other than that, i pretty much dislike this directory-based special-casing. i
> think my suggestion with "file -z" (or equivalent) is much cleaner. 

I agree directory based conditionals are not ideal, but standard unix directory 
structures are a poor man's file type, and it's fast and it works.  The only 
trouble is if you move a log file out of '/var/log' 'mc' would think the log 
file was a man page.  Better than nothing though, and no speed hit.

A 'file -z' clause wouldn't be locationally challenged, but it'd be slower.  

	file -z /var/log/syslog.1.gz
	/var/log/syslog.1.gz: regular file,

	file -z /usr/man/man1/debclean.1.gz
	/usr/man/man1/debclean.1.gz: ASCII troff or preprocessor input text (gzip 
compressed data, was "debclean.1", from Unix, max compression)

...then you've got to parse the output of that.  Using substitutions like '##' 
would make that quick, but if substitutions are taboo, then it'd have to be 
'grep'.  Sample compressed man code:

        View=%view{ascii,nroff} t=`file -z %f | grep troff` ; if [ -z "$t"  ] ; 
then  gzip -dc %f  ; else   gzip -dc %f | nroff -c -Tlatin1 -mandoc ;  fi 

This assumes 'troff' is a good magic word for man pages.  Mostly it is, but how 
do you parse for this?

	file -z /usr/man/man1/sync.1.gz
	/usr/man/man1/sync.1.gz: ASCII English text (gzip compressed data, was 
"sync.1", from Unix, max compression)

Apart from the directory name, there ain't nuthin there!  :(

Most efficient of all would be a new file type attribute created either when 
the file is first made, or on some regular basis, (like the locate database).  
"Never do at run time what you can do at compile time" goes the motto.  The new 
ReiserFS offers many possibilities for this sort of thing.

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.
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.

   ---- File information -----------
     File:  mc.ext.2nd.patch
     Date:  27 May 2003, 2:02
     Size:  1663 bytes.
     Type:  Unknown

Attachment: mc.ext.2nd.patch
Description: Binary data

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]