-/* $OpenBSD: def.h,v 1.166 2020/02/09 10:13:13 florian Exp $ */
+/* $OpenBSD: def.h,v 1.167 2021/02/23 08:10:51 lum Exp $ */
/* This file is in the public domain. */
int ffgetline(FILE *, char *, int, int *);
int fbackupfile(const char *);
char *adjustname(const char *, int);
-char *startupfile(char *);
+char *startupfile(char *, char *);
int copy(char *, char *);
struct list *make_file_list(char *);
int fisdir(const char *);
-/* $OpenBSD: fileio.c,v 1.106 2019/06/22 10:21:57 lum Exp $ */
+/* $OpenBSD: fileio.c,v 1.107 2021/02/23 08:10:51 lum Exp $ */
/* This file is in the public domain. */
* to the startup file name.
*/
char *
-startupfile(char *suffix)
+startupfile(char *suffix, char *conffile)
{
static char file[NFILEN];
char *home;
if ((home = getenv("HOME")) == NULL || *home == '\0')
goto nohome;
- if (suffix == NULL) {
+ if (conffile != NULL) {
+ (void)strncpy(file, conffile, NFILEN);
+ } else if (suffix == NULL) {
ret = snprintf(file, sizeof(file), _PATH_MG_STARTUP, home);
if (ret < 0 || ret >= sizeof(file))
return (NULL);
-/* $OpenBSD: main.c,v 1.87 2019/06/22 15:38:15 lum Exp $ */
+/* $OpenBSD: main.c,v 1.88 2021/02/23 08:10:51 lum Exp $ */
/* This file is in the public domain. */
static __dead void
usage()
{
- fprintf(stderr, "usage: %s [-nR] [-f mode] [+number] [file ...]\n",
+ fprintf(stderr, "usage: %s [-nR] [-f mode] [-u file] [+number] "
+ "[file ...]\n",
__progname);
exit(1);
}
int
main(int argc, char **argv)
{
- char *cp, *init_fcn_name = NULL;
+ char *cp, *conffile = NULL, *init_fcn_name = NULL;
PF init_fcn = NULL;
int o, i, nfiles;
int nobackups = 0;
NULL) == -1)
err(1, "pledge");
- while ((o = getopt(argc, argv, "nRf:")) != -1)
+ while ((o = getopt(argc, argv, "nRf:u:")) != -1)
switch (o) {
case 'R':
allbro = 1;
"initial function");
init_fcn_name = optarg;
break;
+ case 'u':
+ conffile = optarg;
+ break;
default:
usage();
}
update(CMODE);
/* user startup file. */
- if ((cp = startupfile(NULL)) != NULL)
+ if ((cp = startupfile(NULL, conffile)) != NULL)
(void)load(cp);
/*
-.\" $OpenBSD: mg.1,v 1.118 2019/11/08 19:54:40 solene Exp $
+.\" $OpenBSD: mg.1,v 1.119 2021/02/23 08:10:51 lum Exp $
.\" This file is in the public domain.
.\"
-.Dd $Mdocdate: November 8 2019 $
+.Dd $Mdocdate: February 23 2021 $
.Dt MG 1
.Os
.Sh NAME
.Nm mg
.Op Fl nR
.Op Fl f Ar mode
+.Op Fl u Ar file
.Op + Ns Ar number
.Op Ar
.Sh DESCRIPTION
Run the mode command for all buffers created from
arguments on the command line, including the
scratch buffer and all files.
+.It Fl u Ar file
+Use
+.Ar file
+as the startup file, instead of the default
+.Pa ~/.mg .
.It Fl n
Turn off backup file generation.
.It Fl R
-/* $OpenBSD: ttykbd.c,v 1.19 2017/12/17 14:37:57 bcallah Exp $ */
+/* $OpenBSD: ttykbd.c,v 1.20 2021/02/23 08:10:51 lum Exp $ */
/* This file is in the public domain. */
dobindkey(fundamental_map, "delete-char", key_dc);
if ((cp = getenv("TERM"))) {
- if (((cp = startupfile(cp)) != NULL) && (load(cp) != TRUE))
+ if (((cp = startupfile(cp, NULL)) != NULL) &&
+ (load(cp) != TRUE))
ewprintf("Error reading key initialization file");
}
if (keypad_xmit)