[Bug 13] Bootscripts clean up

bugzilla at linuxfromscratch.org bugzilla at linuxfromscratch.org
Tue Sep 25 14:44:26 PDT 2001


http://bugs.linuxfromscratch.org/show_bug.cgi?id=13





------- Additional Comments From gerard at linuxfromscratch.org  2001-09-25 14:44 -------
>From Matthias:


0>&1 makes stdin become a copy of stdout. It's not really useful for           
                                                                               
      
programs that actually read from stdin (because you can't normally read        
                                                                               
      
from stdout). But stty reads the terminal settings which is a different        
                                                                               
      
matter. What we want to achieve in the boot script is to find out the          
                                                                               
      
width of our terminal and store it in COLUMNS. There are 3 possible ways       
                                                                               
      
                                                                               
                                                                               
      
COLUMNS=$(stty size)           #analyses stdin                                 
                                                                               
      
                                                                               
                                                                               
      
COLUMNS=$(stty size 0>&1)  #analyses stdout                                    
                                                                               
      
                                                                               
                                                                               
      
COLUMNS=$(stty size 0>&2)   #analyses stderr                                   
                                                                               
      
                                                                               
                                                                               
      
                                                                               
                                                                               
      
The second is what we want to do but it doesn't work because the stdout we     
                                                                               
      
want to analyse is the stdout of the boot script (our console) that            
                                                                               
      
contains the command. However as I already mentioned, the $(...) redirects     
                                                                               
      
stdout, so that it no longer connects to the console.                          
                                                                               
      
The first variant is the simplest of course and should be used if it           
                                                                               
      
works. Whether it works depends on whether sysvinit opens the console as       
                                                                               
      
stdin for the scripts it starts. It should certainly do so.                    
                                                                               
      
The 3rd variant is like the 2nd variant only that it works on stderr. The      
                                                                               
      
$(...) construct does not redirect stderr, so this is the stderr of the        
                                                                               
      
script, which should be connected to the console.
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-book' in the subject header of the message



More information about the lfs-book mailing list