Skip to content

Commit

Permalink
[Config Save] Error happen when config save a filename with quotation…
Browse files Browse the repository at this point in the history
… mark

When the filename passed to the CLI command 'config save' contains the
special character - double quote, it needs to add an escape character
'\' before the double quote to let bash treat it as a literal character.

However, the filename passed into the python code also contains the
escape character and it will cause a 'file-not-found' error when simply
passes that filename to 'read_json_file()'.

To fix the error, use 'echo' command with the filename to strip the
special character.
  • Loading branch information
rayxhuangEC committed Aug 18, 2022
1 parent 6fc4f15 commit b499795
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,9 @@ def save(filename):
log.log_info("'save' executing...")
clicommon.run_command(command, display_cmd=True)

command = "echo " + file
file = subprocess.getoutput(command)

config_db = sort_dict(read_json_file(file))
with open(file, 'w') as config_db_file:
json.dump(config_db, config_db_file, indent=4)
Expand Down

0 comments on commit b499795

Please sign in to comment.