diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php
index e6ff7da9d..3398cef69 100644
--- a/src/Composer/Console/Application.php
+++ b/src/Composer/Console/Application.php
@@ -207,6 +207,12 @@ class Application extends BaseApplication
if (function_exists('posix_getuid') && posix_getuid() === 0) {
if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
$io->writeError('Do not run Composer as root/super user! See https://getcomposer.org/root for details');
+
+ if ($io->isInteractive()) {
+ if (!$io->askConfirmation('Continue as root/super user [yes]? ', true)) {
+ return 1;
+ }
+ }
}
if ($uid = (int) getenv('SUDO_UID')) {
// Silently clobber any sudo credentials on the invoking user to avoid privilege escalations later on