2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
9 static char sccsid
[] = "$Id: ex_mkexrc.c,v 8.8 1993/12/02 10:49:53 bostic Exp $ (Berkeley) $Date: 1993/12/02 10:49:53 $";
12 #include <sys/types.h>
24 #include "pathnames.h"
27 * ex_mkexrc -- :mkexrc[!] [file]
29 * Create (or overwrite) a .exrc file with the current info.
32 ex_mkexrc(sp
, ep
, cmdp
)
47 fname
= cmdp
->argv
[0]->bp
;
48 set_alt_name(sp
, fname
);
54 if (!F_ISSET(cmdp
, E_FORCE
) && !stat(fname
, &sb
)) {
56 "%s exists, not written; use ! to override.", fname
);
60 /* Create with max permissions of rw-r--r--. */
61 if ((fd
= open(fname
, O_CREAT
| O_TRUNC
| O_WRONLY
,
62 S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IROTH
)) < 0) {
63 msgq(sp
, M_SYSERR
, fname
);
67 if ((fp
= fdopen(fd
, "w")) == NULL
) {
74 if (abbr_save(sp
, fp
) || ferror(fp
))
76 if (map_save(sp
, fp
) || ferror(fp
))
78 if (opts_save(sp
, fp
) || ferror(fp
))
86 msgq(sp
, M_INFO
, "New .exrc file: %s. ", fname
);
92 e2
: msgq(sp
, M_ERR
, "%s: incomplete: %s", fname
, strerror(errno
));