[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
coreutils, dircolors, rc support
From: |
Daniel C. Bastos |
Subject: |
coreutils, dircolors, rc support |
Date: |
Sun, 23 Dec 2007 16:02:45 -0500 |
Hi there. I've patched dircolors to support the rc shell syntax. The
source code I used was coreutils 5.97 from the GNU Debian's apt-get etch
source repository. If I can help with anything else, shoot me a line.
http://math.utoledo.edu/~dbastos/files/patch/rc-dircolors-patch.diff
For an immediate overview:
--- ./dircolors.c 2005-11-06 03:36:03.000000000 -0500
+++ ./rc-dircolors.c 2007-12-23 15:19:21.000000000 -0500
@@ -46,6 +46,7 @@ enum Shell_syntax
{
SHELL_SYNTAX_BOURNE,
SHELL_SYNTAX_C,
+ SHELL_SYNTAX_RC,
SHELL_SYNTAX_UNKNOWN
};
@@ -86,6 +87,8 @@ static struct option const long_options[
{"sh", no_argument, NULL, 'b'},
{"csh", no_argument, NULL, 'c'},
{"c-shell", no_argument, NULL, 'c'},
+ {"rc", no_argument, NULL, 'r'},
+ {"plan9-shell", no_argument, NULL, 'r'},
{"print-database", no_argument, NULL, 'p'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
@@ -109,6 +112,7 @@ Output commands to set the LS_COLORS env
Determine format of output:\n\
-b, --sh, --bourne-shell output Bourne shell code to set
LS_COLORS\n\
-c, --csh, --c-shell output C shell code to set LS_COLORS\n\
+ -r, --rc, --plan9-shell output rc shell code to set LS_COLORS\n\
-p, --print-database output defaults\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
@@ -125,8 +129,7 @@ For details on the format of these files
exit (status);
}
-/* If the SHELL environment variable is set to `csh' or `tcsh,'
- assume C shell. Else Bourne shell. */
+/* Decide which shell syntax to use */
static enum Shell_syntax
guess_shell_syntax (void)
@@ -142,6 +145,9 @@ guess_shell_syntax (void)
if (STREQ (shell, "csh") || STREQ (shell, "tcsh"))
return SHELL_SYNTAX_C;
+ if (STREQ (shell, "rc"))
+ return SHELL_SYNTAX_RC;
+
return SHELL_SYNTAX_BOURNE;
}
@@ -416,7 +422,7 @@ main (int argc, char **argv)
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL))
!= -1)
+ while ((optc = getopt_long (argc, argv, "bcpr", long_options, NULL))
!= -1)
switch (optc)
{
case 'b': /* Bourne shell syntax. */
@@ -427,6 +433,10 @@ main (int argc, char **argv)
syntax = SHELL_SYNTAX_C;
break;
+ case 'r': /* rc shell syntax. */
+ syntax = SHELL_SYNTAX_RC;
+ break;
+
case 'p':
print_database = true;
break;
@@ -442,8 +452,7 @@ main (int argc, char **argv)
argc -= optind;
argv += optind;
- /* It doesn't make sense to use --print with either of
- --bourne or --c-shell. */
+ /* It doesn't make sense to use --print with a shell syntax */
if (print_database && syntax != SHELL_SYNTAX_UNKNOWN)
{
error (0, 0,
@@ -502,6 +511,11 @@ to select a shell syntax are mutually ex
prefix = "LS_COLORS='";
suffix = "';\nexport LS_COLORS\n";
}
+ else if (syntax == SHELL_SYNTAX_RC)
+ {
+ prefix = "LS_COLORS='";
+ suffix = "'\n";
+ }
else
{
prefix = "setenv LS_COLORS '";
- coreutils, dircolors, rc support,
Daniel C. Bastos <=