+ char *line = NULL;
+ bool fail = 0;
+ size_t n;
+
+ while (do_readline(&line, &n, batch)) {
+ int rc = run_command(line, batch);
+ if (rc > 0)
+ break;
+ if (rc < 0)
+ fail = batch;
+ }
+
+ free(line);
+ return fail ? EXIT_FAILURE : 0;
+}
+
+static int repl_cmdline(unsigned count, char **commands)
+{
+ bool fail = 0;
+ unsigned i;
+
+ for (i = 0; i < count; i++) {
+ int rc = run_command(commands[i], true);
+ if (rc > 0)
+ break;
+ if (rc < 0)
+ fail = true;
+ }
+
+ return fail ? EXIT_FAILURE : 0;
+}
+
+/* Initialize gettext */
+static void init_i18n(void)
+{
+ if (!ENABLE_NLS)
+ return;
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+}
+
+enum {
+ INIT_EXIT_SUCCESS = -1,
+ INIT_EXIT_FAILURE = -2
+};
+
+static int initialize(int argc, char **argv)
+{
+ int i, opt, quiet = 0, execute = 0;
+ const char *filename = NULL;
+
+ XTRA_PACKED_LOPTS(lopts);