#include <sys/file.h>
#include <signal.h>
#include <errno.h>
+#include <err.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
int qflg = 0;
int tflg = 0;
-static char *progname;
-
int die;
int resized;
die_if_link(char *fn) {
struct stat s;
- if (lstat(fn, &s) == 0 && (S_ISLNK(s.st_mode) || s.st_nlink > 1)) {
- fprintf(stderr,
+ if (lstat(fn, &s) == 0 && (S_ISLNK(s.st_mode) || s.st_nlink > 1))
+ /* FIXME: there is no [options] to allow/force this to happen. */
+ errx(EXIT_FAILURE,
_("Warning: `%s' is a link.\n"
"Use `%s [options] %s' if you really "
"want to use it.\n"
- "Script not started.\n"),
- fn, progname, fn);
- exit(1);
- }
+ "Program not started.\n"),
+ fn, program_invocation_short_name, fn);
}
/*
sigset_t block_mask, unblock_mask;
struct sigaction sa;
extern int optind;
- char *p;
int ch;
- progname = argv[0];
- if ((p = strrchr(progname, '/')) != NULL)
- progname = p+1;
-
-
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C"); /* see comment above */
bindtextdomain(PACKAGE, LOCALEDIR);
if (argc == 2) {
if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) {
printf(_("%s (%s)\n"),
- progname, PACKAGE_STRING);
+ program_invocation_short_name, PACKAGE_STRING);
return 0;
}
}
die_if_link(fname);
}
if ((fscript = fopen(fname, aflg ? "a" : "w")) == NULL) {
- perror(fname);
+ warn(_("open failed: %s"), fname);
fail();
}
sigprocmask(SIG_SETMASK, &unblock_mask, NULL);
if (child < 0) {
- perror("fork");
+ warn(_("fork failed"));
fail();
}
if (child == 0) {
sigprocmask(SIG_SETMASK, &unblock_mask, NULL);
if (child < 0) {
- perror("fork");
+ warn(_("fork failed"));
fail();
}
if (child)
}
doinput();
- return 0;
+ return EXIT_SUCCESS;
}
void
if ((cc = read(0, ibuf, BUFSIZ)) > 0) {
ssize_t wrt = write(master, ibuf, cc);
if (wrt == -1) {
- int err = errno;
- fprintf (stderr, _("%s: write error %d: %s\n"),
- progname, err, strerror(err));
+ warn (_("write failed"));
fail();
}
}
}
wrt = write(1, obuf, cc);
if (wrt < 0) {
- int err = errno;
- fprintf (stderr, _("%s: write error: %s\n"),
- progname, strerror(err));
+ warn (_("write failed"));
fail();
}
fwrt = fwrite(obuf, 1, cc, fscript);
if (fwrt < cc) {
- int err = errno;
- fprintf (stderr, _("%s: cannot write script file, error: %s\n"),
- progname, strerror(err));
+ warn (_("cannot write script file"));
fail();
}
if (fflg)
else
execl(shell, shname, "-i", NULL);
- perror(shell);
+ warn(_("failed to execute %s"), shell);
fail();
}
else
exit(WEXITSTATUS(childstatus));
}
- exit(0);
+ exit(EXIT_SUCCESS);
}
void
(void) tcgetattr(0, &tt);
(void) ioctl(0, TIOCGWINSZ, (char *)&win);
if (openpty(&master, &slave, NULL, &tt, &win) < 0) {
- fprintf(stderr, _("openpty failed\n"));
+ warn(_("openpty failed"));
fail();
}
#else
}
}
master = -1;
- fprintf(stderr, _("Out of pty's\n"));
+ warn(_("out of pty's"));
fail();
#endif /* not HAVE_LIBUTIL */
}
line[strlen("/dev/")] = 't';
slave = open(line, O_RDWR);
if (slave < 0) {
- perror(line);
+ warn(_("open failed: %s"), line);
fail();
}
(void) tcsetattr(slave, TCSANOW, &tt);