fix #556 fuckup, fixes #624

This commit is contained in:
ed 2025-08-17 15:19:25 +00:00
parent e7f2c6d806
commit bf1fdcab09

View file

@ -441,15 +441,8 @@ def expand_cfg(argv) -> list[str]:
supp = args_from_cfg(CFG_DEF[0])
argv = supp + argv
n = spins = 0
n = 0
while n < len(argv):
if not n:
if spins % 1000 == 999:
t = "still expanding config files... giving up after %d more"
print(t % (9999 - spins))
if spins > 9999:
t = "got stuck expanding config files; do you have a config-file which imports itself? this is where I gave up:\n%r"
raise Exception(t % (argv[:1000]))
v1 = argv[n]
v1v = v1[2:].lstrip("=")
try:
@ -457,16 +450,12 @@ def expand_cfg(argv) -> list[str]:
except:
v2 = ""
n += 1
if v1 == "-c" and v2 and os.path.isfile(v2):
argv = argv[:n] + args_from_cfg(v2) + argv[n + 2 :]
spins += 1
n = 0
elif v1.startswith("-c") and v1v and os.path.isfile(v1v):
argv = argv[:n] + args_from_cfg(v1v) + argv[n + 1 :]
spins += 1
n = 0
else:
n += 1
argv = argv[:n] + args_from_cfg(v2) + argv[n:]
elif v1.startswith("-c") and v1v and os.path.isfile(v1v):
argv = argv[:n] + args_from_cfg(v1v) + argv[n:]
return argv