diff --git a/src/azure-cli-core/azure/cli/core/application.py b/src/azure-cli-core/azure/cli/core/application.py index 68cbc5273b2..e9f63459417 100644 --- a/src/azure-cli-core/azure/cli/core/application.py +++ b/src/azure-cli-core/azure/cli/core/application.py @@ -202,13 +202,15 @@ def _register_builtin_arguments(**kwargs): @staticmethod def _maybe_load_file(arg): ix = arg.find('@') - if ix == -1: + if ix == -1: # not found + return arg + + if ix == len(arg) - 1: # allow simply the value '@' (used by DNS for example) return arg if ix == 0: return Application._load_file(arg[1:]) - - if arg[ix - 1] == '=': + elif arg[ix - 1] == '=': return arg[:ix] + Application._load_file(arg[ix + 1:]) return arg @@ -225,7 +227,7 @@ def _load_file(path): if path == '-': content = sys.stdin.read() else: - with open(path, 'r') as input_file: + with open(os.path.expanduser(path), 'r') as input_file: content = input_file.read() return content[0:-1] if content[-1] == '\n' else content