# ! / b i n / s h 
 
 
 #   T h e   o r i g i n a l   v e r s i o n   f o r   g z i p   w a s   w r i t t e n   b y   P a u l   E g g e r t . 
 #   M o d i f i e d   f o r   X Z   U t i l s   b y   A n d r e w   D u d m a n   a n d   L a s s e   C o l l i n . 
 # ) ! 
 
 # S E T _ P A T H   -   T h i s   l i n e   i s   a   p l a c e h o l d e r   t o   e a s e   p a t c h i n g   t h i s   s c r i p t . 
 
 #   I n s t e a d   o f   u n s e t t i n g   X Z _ O P T ,   j u s t   m a k e   s u r e   t h a t   x z   w i l l   u s e   f i l e   f o r m a t 
 #   a u t o d e t e c t i o n .   T h i s   w a y   m e m o r y   u s a g e   l i m i t   a n d   t h r e a d   l i m i t   c a n   b e 
 #   s p e c i f i e d   v i a   X Z _ O P T . 
 x z = ' x z   - - f o r m a t = a u t o ' 
 
 v e r s i o n = ' x z l e s s   ( X Z   U t i l s )   5 . 1 . 4 b e t a ' 
 
 u s a g e = " U s a g e :   $ { 0 # # * / }   [ O P T I O N ] . . .   [ F I L E ] . . . 
 L i k e   ' l e s s ' ,   b u t   o p e r a t e   o n   t h e   u n c o m p r e s s e d   c o n t e n t s   o f   x z   c o m p r e s s e d   F I L E s . 
 
 O p t i o n s   a r e   t h e   s a m e   a s   f o r   ' l e s s ' . 
 
 R e p o r t   b u g s   t o   < l a s s e . c o l l i n @ t u k a a n i . o r g > . " 
 
 c a s e   $ 1   i n 
 	 - - h e l p )         e c h o   " $ u s a g e "   | |   e x i t   2 ;   e x i t ; ; 
 	 - - v e r s i o n )   e c h o   " $ v e r s i o n "   | |   e x i t   2 ;   e x i t ; ; 
 e s a c 
 
 i f   t e s t   " $ { L E S S M E T A C H A R S + s e t } "   ! =   s e t ;   t h e n 
 	 #   W o r k   a r o u n d   a   b u g   i n   l e s s   3 9 4   a n d   e a r l i e r ; 
 	 #   i t   m i s h a n d l e s   t h e   m e t a c h a r a c t e r s   ' $ % = ~ ' . 
 	 s p a c e = '   ' 
 	 t a b = ' 	 ' 
 	 n l = ' 
 ' 
 	 L E S S M E T A C H A R S = " $ s p a c e $ t a b $ n l ' " ' ; * ? " ( ) < > [ | & ^ ` # \ $ % = ~ ' 
 f i 
 
 i f   t e s t   " $ ( l e s s   - V   |   {   r e a d   l e s s   v e r   r e   & &   e c h o   $ { v e r } ;   } ) "   - g e   4 2 9 ;   t h e n 
 	 #   l e s s   4 2 9   o r   l a t e r :   L E S S O P E N   p i p e   w i l l   b e   u s e d   o n 
 	 #   s t a n d a r d   i n p u t   i f   $ L E S S O P E N   b e g i n s   w i t h   | - . 
 	 L E S S O P E N = " | - $ x z   - c d f q   - -   % s " 
 e l s e 
 	 L E S S O P E N = " | $ x z   - c d f q   - -   % s " 
 f i 
 e x p o r t   L E S S M E T A C H A R S   L E S S O P E N 
 
 e x e c   l e s s   " $ @ " 
 