summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2022-12-20 15:32:49 +0200
committerTimo Teräs <timo.teras@iki.fi>2022-12-20 15:35:05 +0200
commitaf6e2c757e193006e303c9377b37d817364eda7a (patch)
tree62373fb9a439f721b5fd26d8a31207b0e0a2a653
parentcb6742953386cb958e52d90ec9198fb8f65c3a71 (diff)
downloadapk-tools-af6e2c757e193006e303c9377b37d817364eda7a.tar.gz
apk-tools-af6e2c757e193006e303c9377b37d817364eda7a.tar.bz2
apk-tools-af6e2c757e193006e303c9377b37d817364eda7a.tar.xz
apk-tools-af6e2c757e193006e303c9377b37d817364eda7a.zip
apk: improve interactive mode handling
- implement and document --no-interactive - improve --interactive documentation - treat EOF as Y fixes #10860
-rw-r--r--doc/apk.8.scd5
-rw-r--r--src/apk.c4
-rw-r--r--src/commit.c2
3 files changed, 10 insertions, 1 deletions
diff --git a/doc/apk.8.scd b/doc/apk.8.scd
index 7b104a5..e749e67 100644
--- a/doc/apk.8.scd
+++ b/doc/apk.8.scd
@@ -81,6 +81,8 @@ The following options are available for all commands.
*-i, --interactive*
Ask confirmation before performing certain operations.
+ Interactive mode can be made the default when running on a tty,
+ by creating /etc/apk/interactive as an empty file.
*-p, --root* <_ROOT_>
Manage file system at _ROOT_.
@@ -144,6 +146,9 @@ The following options are available for all commands.
*--no-cache*
Do not use any local cache path.
+*--no-interactive*
+ Disable interactive mode.
+
*--no-network*
Do not use the network. The cache is still used when possible.
diff --git a/src/apk.c b/src/apk.c
index 2c5fddf..1340086 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -71,6 +71,7 @@ static void version(struct apk_out *out, const char *prefix)
OPT(OPT_GLOBAL_interactive, APK_OPT_SH("i") "interactive") \
OPT(OPT_GLOBAL_keys_dir, APK_OPT_ARG "keys-dir") \
OPT(OPT_GLOBAL_no_cache, "no-cache") \
+ OPT(OPT_GLOBAL_no_interactive, "no-interactive") \
OPT(OPT_GLOBAL_no_logfile, "no-logfile") \
OPT(OPT_GLOBAL_no_network, "no-network") \
OPT(OPT_GLOBAL_no_progress, "no-progress") \
@@ -156,6 +157,9 @@ static int option_parse_global(void *ctx, struct apk_ctx *ac, int opt, const cha
case OPT_GLOBAL_interactive:
ac->flags |= APK_INTERACTIVE;
break;
+ case OPT_GLOBAL_no_interactive:
+ ac->flags &= ~APK_INTERACTIVE;
+ break;
case OPT_GLOBAL_preserve_env:
ac->flags |= APK_PRESERVE_ENV;
break;
diff --git a/src/commit.c b/src/commit.c
index 0096a9a..3476cd1 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -321,7 +321,7 @@ int apk_solver_commit_changeset(struct apk_database *db,
printf("Do you want to continue [Y/n]? ");
fflush(stdout);
r = fgetc(stdin);
- if (r != 'y' && r != 'Y' && r != '\n')
+ if (r != 'y' && r != 'Y' && r != '\n' && r != EOF)
return -1;
}
}