From: Sai Vishnu M <saivishnu725@xxxxxxxxx> 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@xxxxxxxxx> --- 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