From 474fdd028c106ded871f633d096e753ae227c0c0 Mon Sep 17 00:00:00 2001 From: dissimulo Date: Sun, 17 May 2026 02:14:29 -0700 Subject: [PATCH] Rakefile: handle non-interactive stdin in ask() STDIN.gets returns nil when stdin is closed/EOF (e.g. after vim/vundle runs during install), causing `nil.chomp` to abort rake install during install_term_theme. Return nil from ask() on EOF and have callers bail out of the iTerm theme prompts gracefully. --- Rakefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index b600f276..7db1d1db 100644 --- a/Rakefile +++ b/Rakefile @@ -210,7 +210,7 @@ def install_term_theme message = "Which theme would you like to apply to your iTerm2 profile?" color_scheme = ask message, iTerm_available_themes - return if color_scheme == 'None' + return if color_scheme.nil? || color_scheme == 'None' color_scheme_file = File.join('iTerm2', "#{color_scheme}.itermcolors") @@ -220,6 +220,8 @@ def install_term_theme profiles << 'All' selected = ask message, profiles + return if selected.nil? + if selected == 'All' (profiles.size-1).times { |idx| apply_theme_to_iterm_profile_idx idx, color_scheme_file } else @@ -244,7 +246,12 @@ def ask(message, values) puts message while true values.each_with_index { |val, idx| puts " #{idx+1}. #{val}" } - selection = STDIN.gets.chomp + input = STDIN.gets + if input.nil? + puts "(no input available — skipping prompt)" + return nil + end + selection = input.chomp if (Float(selection)==nil rescue true) || selection.to_i < 0 || selection.to_i > values.size+1 puts "ERROR: Invalid selection.\n\n" else