summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--ChangeLog10
-rw-r--r--NEWS4
-rw-r--r--doc/ratpoison.13
-rw-r--r--doc/ratpoison.texi7
-rw-r--r--src/main.c76
6 files changed, 72 insertions, 29 deletions
diff --git a/AUTHORS b/AUTHORS
index 747c2eb..7727831 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -29,3 +29,4 @@ Tim Goodwin <tjg@star.le.ac.uk>
Joshua Neuheisel <jneuheisel@msn.com>
Thien-Thi Nguyen <ttn@glug.org>
Joshua Neuheisel <jneuheisel@msn.com>
+Sylvain BEUCLER <beuc@beuc.net>
diff --git a/ChangeLog b/ChangeLog
index 78d006a..353bba7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-11-24 Shawn Betts <sabetts@vcn.bc.ca>
+
+ * src/main.c (ratpoison_longopts): add "file"
+ (ratpoison_opts): add f: option
+ (print_help): print help for --file option
+ (read_startup_files): take an alternative rc file as an argument
+ and use it if it is non-NULL.
+ (main): parse the --file option. pass alt_rcfile to
+ read_startup_files.
+
2003-11-22 Shawn Betts <sabetts@vcn.bc.ca>
* contrib/Makefile.am (pkgdata_DATA): add rpshowall.sh
diff --git a/NEWS b/NEWS
index 1e4d0fb..450c2b6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
ratpoison NEWS --- history of user-visible changes. -*- outline -*-
+* Changes since 1.3.0-rc1
+** new command-line option --file
+Used to specify an alternate configuration file.
+
* Changes since 1.3.0-beta3
** new configure option --disable-history
diff --git a/doc/ratpoison.1 b/doc/ratpoison.1
index 37fb3fa..b7dacf2 100644
--- a/doc/ratpoison.1
+++ b/doc/ratpoison.1
@@ -492,6 +492,9 @@ Display the version
.TP
.B \-c \fIcmd\fP, \-\-command \fIcmd\fP
Send ratpoison a colon\-command.
+.TP
+.B \-f \fIfilename\fP, \-\-file \fIfilename\fP
+Specify an alternate configuration file.
.SH FILES
.TP
.B /etc/ratpoisonrc
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index 6f22aff..e0aa159 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -1252,6 +1252,9 @@ Here ratpoison would split the current frame twice.
Force ratpoison to execute commands in interactive mode. This is used
in conjuction with the @option{-c} option.
+@item -f, --file
+Specify an alternate configuration file. @xref{Startup file}.
+
@end table
@node Startup file, Command Index, Command Line Arguments, Top
@@ -1270,6 +1273,10 @@ tries @file{/etc/ratpoisonrc}. This means any command you can bind a key
to or run at the command prompt (@kbd{C-t :}) you can execute in this rc
file.
+You can also use the @option{-f} option to specify another startup
+file, allowing you to switch between different configurations
+(@pxref{Command Line Arguments}).
+
@node Command Index, , Startup file, Top
@unnumbered Command Index
diff --git a/src/main.c b/src/main.c
index e252d75..bcec4f6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,9 +54,10 @@ static struct option ratpoison_longopts[] =
{"command", required_argument, 0, 'c'},
{"display", required_argument, 0, 'd'},
{"screen", required_argument, 0, 's'},
+ {"file", required_argument, 0, 'f'},
{0, 0, 0, 0} };
-static char ratpoison_opts[] = "hvic:d:s:";
+static char ratpoison_opts[] = "hvic:d:s:f:";
void
fatal (const char *msg)
@@ -291,7 +292,8 @@ print_help ()
printf ("-d, --display <dpy> Set the X display to use\n");
printf ("-s, --screen <num> Only use the specified screen\n");
printf ("-c, --command <cmd> Send ratpoison a colon-command\n");
- printf ("-i, --interactive Execute commands in interactive mode\n\n");
+ printf ("-i, --interactive Execute commands in interactive mode\n");
+ printf ("-f, --file <file> Specify an alternative configuration file\n\n");
printf ("Report bugs to ratpoison-devel@lists.sourceforge.net\n\n");
@@ -363,44 +365,54 @@ read_rc_file (FILE *file)
}
static void
-read_startup_files ()
+read_startup_files (char *alt_rcfile)
{
char *homedir;
- FILE *fileptr;
+ FILE *fileptr = NULL;
- /* first check $HOME/.ratpoisonrc and if that does not exist then try
- /etc/ratpoisonrc */
-
- homedir = getenv ("HOME");
- if (!homedir)
+ if (alt_rcfile)
{
- PRINT_ERROR (("ratpoison: $HOME not set!?\n"));
+ if ((fileptr = fopen (alt_rcfile, "r")) == NULL)
+ {
+ /* we probably don't need to report this, its not an error */
+ PRINT_DEBUG (("ratpoison: could not open %s\n", alt_rcfile));
+ }
}
else
{
- char *filename = (char*)xmalloc (strlen (homedir) + strlen ("/.ratpoisonrc") + 1);
- sprintf (filename, "%s/.ratpoisonrc", homedir);
-
- if ((fileptr = fopen (filename, "r")) == NULL)
- {
- /* we probably don't need to report this, its not an error */
- PRINT_DEBUG (("ratpoison: could not open %s\n", filename));
+ /* first check $HOME/.ratpoisonrc and if that does not exist then try
+ /etc/ratpoisonrc */
- if ((fileptr = fopen ("/etc/ratpoisonrc", "r")) == NULL)
- {
- /* neither is this */
- PRINT_DEBUG (("ratpoison: could not open /etc/ratpoisonrc\n"));
- }
+ homedir = getenv ("HOME");
+ if (!homedir)
+ {
+ PRINT_ERROR (("ratpoison: $HOME not set!?\n"));
}
-
- if (fileptr)
+ else
{
- set_close_on_exec(fileptr);
- read_rc_file (fileptr);
- fclose (fileptr);
+ char *filename = (char*)xmalloc (strlen (homedir) + strlen ("/.ratpoisonrc") + 1);
+ sprintf (filename, "%s/.ratpoisonrc", homedir);
+
+ if ((fileptr = fopen (filename, "r")) == NULL)
+ {
+ /* we probably don't need to report this, its not an error */
+ PRINT_DEBUG (("ratpoison: could not open %s\n", filename));
+
+ if ((fileptr = fopen ("/etc/ratpoisonrc", "r")) == NULL)
+ {
+ /* neither is this */
+ PRINT_DEBUG (("ratpoison: could not open /etc/ratpoisonrc\n"));
+ }
+ }
+ free (filename);
}
+ }
- free (filename);
+ if (fileptr)
+ {
+ set_close_on_exec(fileptr);
+ read_rc_file (fileptr);
+ fclose (fileptr);
}
}
@@ -497,6 +509,7 @@ main (int argc, char *argv[])
int screen_num = 0;
char *display = NULL;
unsigned char interactive = 0;
+ char *alt_rcfile = NULL;
myargv = argv;
@@ -540,6 +553,9 @@ main (int argc, char *argv[])
case 'i':
interactive = 1;
break;
+ case 'f':
+ alt_rcfile = xstrdup (optarg);
+ break;
default:
exit (EXIT_FAILURE);
@@ -653,7 +669,9 @@ main (int argc, char *argv[])
}
}
- read_startup_files ();
+ read_startup_files (alt_rcfile);
+ if (alt_rcfile)
+ free (alt_rcfile);
/* Indicate to the user that ratpoison has booted. */
if (defaults.startup_message)