git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #155162 from ZenithalHourlyRate/command-not-found-interactive

command-not-found: add interactive option for auto run

commit363ef08971726937cd6a63de0efef7f8ba657b18 authorBernardo Meurer <bernardo@meurer.org> dateTue 8 Feb 2022, 15:30 (5 years ago) parentab98adb0358703
1 file changed+11
nixos/modules/programs/command-not-found/command-not-found.pl+11
nixos/modules/programs/command-not-found/command-not-found.pl+11
@@ -28,6 +28,17 @@ if ($len == 0) {
2828} elsif ($len == 1) {
2929 my $package = @$res[0]->{package};
3030 if ($ENV{"NIX_AUTO_RUN"} // "") {
31+ if ($ENV{"NIX_AUTO_RUN_INTERACTIVE"} // "") {
32+ while (1) {
33+ print STDERR "'$program' from package '$package' will be run, confirm? [yn]: ";
34+ chomp(my $comfirm = <STDIN>);
35+ if (lc $comfirm eq "n") {
36+ exit 0;
37+ } elsif (lc $comfirm eq "y") {
38+ last;
39+ }
40+ }
41+ }
3142 exec("nix-shell", "-p", $package, "--run", shell_quote("exec", @ARGV));
3243 } else {
3344 print STDERR <<EOF;