Mail Archives: djgpp/1997/02/05/21:31:42
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 -