fix(install): exchange install option content through UTF-8 files

Windows PowerShell pipes re-encode text by console code page: under code page
65001 a BOM broke the config.toml merge, and otherwise non-ASCII characters
became question marks. Pass managed and merged content through files, and
decode piped input as utf-8-sig.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian lechnerandClaude Opus 5.5 committed 2026-10-01 10:23:14 +02:00
1 parent bed90fee2d
commit 857720bcfd
3 files changed
+51 -12

No files matched your search

+12 -6
View File
@@ -173,18 +173,24 @@ if __name__ == '__main__':
parser.add_argument('--current', type=Path)
parser.add_argument('--flashbang', choices=('true', 'false'))
parser.add_argument('--statusline', choices=('true', 'false'), default='true')
parser.add_argument('--managed', type=Path)
parser.add_argument('--output', type=Path)
args = parser.parse_args()
try:
sys.stdout.reconfigure(encoding='utf-8')
if args.action == 'filter':
print(filter_options(args.path, args.flashbang == 'true', args.statusline == 'true'), end='')
result = filter_options(args.path, args.flashbang == 'true', args.statusline == 'true')
else:
managed = args.managed.read_text(encoding='utf-8-sig') if args.managed else sys.stdin.buffer.read().decode('utf-8-sig')
current = args.current.read_text(encoding='utf-8-sig')
if args.action == 'merge-json':
current = json.loads(args.current.read_text(encoding='utf-8-sig'))
managed = json.load(sys.stdin)
print(json.dumps(merge_json(current, managed), indent=2, ensure_ascii=False) + '\n', end='')
result = json.dumps(merge_json(json.loads(current), json.loads(managed)), indent=2, ensure_ascii=False) + '\n'
else:
print(merge_toml(args.current.read_text(encoding='utf-8-sig'), sys.stdin.read(), args.statusline == 'true'), end='')
result = merge_toml(current, managed, args.statusline == 'true')
if args.output:
args.output.write_text(result, encoding='utf-8', newline='')
else:
sys.stdout.reconfigure(encoding='utf-8')
print(result, end='')
except (OSError, ValueError, KeyError) as error:
print(f'Install options: {error}', file=sys.stderr)
sys.exit(1)