delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/05/21:31:42

From: y0000980 AT ws DOT rz DOT tu-bs DOT de (Andree Borrmann)
Newsgroups: comp.os.msdos.djgpp
Subject: ls options patch
Date: 5 Feb 1997 17:23:02 GMT
Organization: Technische Universitaet Braunschweig, Germany
Lines: 57
Sender: y0000980 AT rz0cosv2 DOT rz DOT tu-bs DOT de (Andree Borrmann)
Distribution: world
Message-ID: <5daflv$s2v@ra.ibr.cs.tu-bs.de>
NNTP-Posting-Host: rz0cosv2.rz.tu-bs.de
Keywords: patch, ls, fileutils
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi.

I think there are a lot people who wants "ls" to have "--color=auto" as default
or any other command switch. So I wrote a patch for ls.
ls then reads option from environment variable "LS_OPTIONS" and process them 
before the one you typed at command-line (so overriding is possible...).
You don't have to waste environment mem because you can add following lines
to your DJGPP.ENV:
[LS]
LS_OPTIONS=--color=auto, -f, --whatever_switch_you_want

(There is already a LS_COLOR variable which defines which color for what file)

Enough of my bad English, here comes the patch:
(You need Gnu patch, fileXXXs.zip & Gnu sed to rebuild the programs)

*** orig/ls.c	Mon Sep 30 10:36:32 1996
--- ls.c	Tue Jan 28 16:34:26 1997
***************
*** 689,694 ****
--- 689,718 ----
    pending_dirs = 0;
    current_time = time ((time_t *) 0);
  
+ 
+   /* Let's look up if there is an environment variables with options:
+    * Simply define a variable LS_OPTIONS with your favourite ls options,
+    * eg.: LS_OPTIONS=--color=auto, -F     (patch by A DOT Borrmann AT tu-bs DOT de) 
+    */
+   if (getenv("LS_OPTIONS"))
+   {
+     char *tok;
+     int  count;
+     
+     for (tok = strtok(getenv("LS_OPTIONS"), " ,"); 
+ 	 tok;                    // May be add ';' to the token delimiters...
+ 	 tok=strtok(0, " ,"))
+       {
+         /* Push the option on commandline down, so they can override
+ 	 * the environment options!
+ 	 */
+ 	for (count = argc; count>0; count--) 
+ 	  argv[count]=argv[count-1];
+ 	argc++;
+ 	argv[1]=tok;
+       }
+   }
+ 
    i = decode_switches (argc, argv);
  
    if (show_version)
--> end of patch <--

Bye,
Andree


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019