linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sai Vishnu M <saivishnu725@gmail.com>
To: corbet@lwn.net, mchehab@kernel.org
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	shuah@kernel.org, Sai Vishnu M <saivishnu725@gmail.com>
Subject: [PATCH 2/4] scripts: sphinx-pre-install: add a helper subroutine
Date: Wed, 25 Jun 2025 21:52:35 +0530	[thread overview]
Message-ID: <20250625162237.3996-2-saivishnu725@gmail.com> (raw)
In-Reply-To: <20250625162237.3996-1-saivishnu725@gmail.com>

From: Sai Vishnu M <saivishnu725@gmail.com>

Implement run_if_interactive subroutine to prompt for command execution.
The script crashes if the command fails to execute properly.

Signed-off-by: Sai Vishnu M <saivishnu725@gmail.com>
---
Patch series history:
1 -> implement the --interactive flag

 scripts/sphinx-pre-install | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/scripts/sphinx-pre-install b/scripts/sphinx-pre-install
index 6e6e5bda6186..16eb739fd633 100755
--- a/scripts/sphinx-pre-install
+++ b/scripts/sphinx-pre-install
@@ -339,6 +339,22 @@ sub which($)
 	return undef;
 }
 
+sub run_if_interactive($)
+{
+	my $command = shift;
+	printf("\n\t$command\n");
+
+	if ($interactive) {
+		printf("Run the command now? [Y/n]: ");
+		my $user_input = <STDIN>;
+		chomp $user_input;
+		if ($user_input eq '' or $user_input =~ /^y(es)?$/i) {
+			system($command) == 0
+				or die "Failed to run the command";
+		}
+	}
+}
+
 #
 # Subroutines that check distro-specific hints
 #
-- 
2.49.0


  reply	other threads:[~2025-06-25 16:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 16:22 [PATCH 1/4] scripts: sphinx-pre-install: Add --interactive flag Sai Vishnu M
2025-06-25 16:22 ` Sai Vishnu M [this message]
2025-06-25 16:22 ` [PATCH 3/4] scripts: sphinx-pre-install: add fallback to distro detection Sai Vishnu M
2025-06-25 16:22 ` [PATCH 4/4] scripts: sphinx-pre-install: Integrate interactive mode Sai Vishnu M
2025-06-25 20:32 ` [PATCH 1/4] scripts: sphinx-pre-install: Add --interactive flag Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250625162237.3996-2-saivishnu725@gmail.com \
    --to=saivishnu725@gmail.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).