global

def expand_path_with_potential_to_path(file, dir = nil)

def expand_path_with_potential_to_path(file, dir = nil)
  raise ArgumentError, 'home not set' if file == '~' && ENV["HOME"] == ''
  expand_path_without_potential_to_path(
    Backports.convert_path(file),
    dir == nil ? dir : Backports.convert_path(dir)
  )
end