From 57419fd12cc84ca88a5f99932359112a64a07ba1 Mon Sep 17 00:00:00 2001 From: Zachary Flower Date: Fri, 16 Feb 2018 13:28:41 -0700 Subject: [PATCH] quick fix to register method --- lib/vagrant/alias.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/alias.rb b/lib/vagrant/alias.rb index 29b924976..caf070fe0 100644 --- a/lib/vagrant/alias.rb +++ b/lib/vagrant/alias.rb @@ -5,10 +5,10 @@ module Vagrant class Alias def initialize(env) @aliases = Registry.new + @env = env - aliases_file = env.home_path.join("aliases") - if aliases_file.file? - aliases_file.readlines.each do |line| + if env.aliases_path.file? + env.aliases_path.readlines.each do |line| # separate keyword-command pairs keyword, command = interpret(line) @@ -31,6 +31,11 @@ module Vagrant keyword, command = line.split("=", 2).collect(&:strip) + # validate the keyword + if keyword.match(/[\s]/i) + raise Errors::AliasInvalidError, alias: line, message: "Alias keywords must not contain any whitespace." + end + [keyword, command] end @@ -43,7 +48,7 @@ module Vagrant return exec "#{command[1..-1]} #{args.join(" ")}".strip end - return CLI.new(command.split.concat(args), env).execute + return CLI.new(command.split.concat(args), @env).execute end end end