X-Spam-Check-By: sourceware.org Message-ID: <452D8E10.9060503@byu.net> Date: Wed, 11 Oct 2006 18:36:32 -0600 From: Eric Blake User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.666 MIME-Version: 1.0 To: cygwin AT cygwin DOT com, stuccio AT gmail DOT com, Phillip DOT Long AT gossinternational DOT com Subject: Re: Problems with 'dircolors' References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > -----Original Message----- > From: cygwin-owner AT cygwin DOT com ^^^^ ^^^^^ Phil, please avoid http://cygwin.com/acronyms/#TOFU (reformatted accordingly) and please http://cygwin.com/acronyms/#PCYMTNQREAIYR (munged raw address accordingly) > Can someone explain me how dircolors work? > I don't understand the concept of the environment variable (in this case > - i think - LS_COLORS) and when i try 'set LS_COLORS --COLOR' it does > nothing at all. Are you using bash or tcsh? If you are using bash, then set is not the right way to do things. The short answer is you use dircolors to output raw shell script, eval that shell snippet to set the LS_COLORS environment variable, set up an alias so that ls is invoked with the --color option, then ls will read the contents of the LS_COLORS environment variable. This is done for you by default if you have not edited any files from the base-files package. According to Long, Phillip GOSS on 10/11/2006 11:41 AM: > Hi, Ricardo! > > `dircolors' comes with its own built-in colorization scheme; that's what > U get when U type `dircolors --print-database.' If U want to > _customize_ your colorization scheme, dump the database to a file, like > this: > dircolors --print-database > dircolors.db > make whatever changes U want, and in your `.bash_profile' file (if U're > using `bash' as your shell), enter this line: > eval $(dircolors -b /path/to/your/file/dircolors.db) Actually, for bash, that should be: eval "$(dircolors -b /path/to/dircolors.db)" Otherwise, the output of dircolors, which contains shell metacharacters, is subject to file globbing, and some well-named files can make this execute arbitrary shell code (well, it's true that on cygwin, it's much harder to make these well-named files, since Windows doesn't allow them by default, but this is for portability to other platforms with more permissive filesystems). tcsh has a similar requirement for properly quoting, but I don't use tcsh to tell you what it should look like. > > Now when U open a window, `dircolors' generates a command to set the > environment variable LS_COLORS. This is executed in a subprocess (it's > inside a `$(...)' construct), and its output is returned as a string > passed to `eval,' which _runs_ that command (which sets the LS_COLORS > environment variable) in the context of the current process (sort of > like using `source' or `.'). You forgot to mention that you must set up an alias or shell function for ls so that it is always invoked with the --color option. Here, if you are a bash user, the directions in /etc/DIR_COLORS are useful - edit ~/.bashrc, and add the line: alias ls='ls -color=auto' - -- Life is short - so eat dessert first! Eric Blake ebb9 AT byu DOT net volunteer cygwin coreutils maintainer -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFLY4Q84KuGfSFAYARApbaAJ9ztgsNtBM2nrR0skKABsN3wz/dwwCgmpZp QcDfpVbIYRb2R4+OtTU2ivY= =Dw71 -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/