From cadc0506f9e94f17f522fdd5c14cfb8bbf228d9b Mon Sep 17 00:00:00 2001 From: Max Howell Date: Mon, 29 Aug 2011 10:24:12 +0100 Subject: cd KNOWN_DIR before executing any functions or tools It is fucking amazing how much shit breaks if CWD is invalid. Fucking amazing. Also fuck you dumb user who can't figure out what "No such file or directory - getcwd" means so you force me to waste half an hour fixing it for you. --- install_homebrew.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install_homebrew.rb b/install_homebrew.rb index ea2bd9b19..07485e4d3 100644 --- a/install_homebrew.rb +++ b/install_homebrew.rb @@ -66,6 +66,10 @@ def macos_version @macos_version ||= /(10\.\d+)(\.\d+)?/.match(`/usr/bin/sw_vers -productVersion`).captures.first.to_f end +# The block form of Dir.chdir fails later if Dir.CWD doesn't exist which I +# guess is fair enough. Also sudo prints a warning message for no good reason +Dir.chdir "/usr" + ####################################################################### script abort "MacOS too old, see: https://gist.github.com/1144389" if macos_version < 10.5 abort "/usr/local/.git already exists!" unless Dir["/usr/local/.git/*"].empty? -- cgit v1.2.3