# Can Bacon read a file that assigns variables like Bash can by sourcing?
IF NOT... Then I came up with this code mess:
The Bacon parser errors on the REPLACE line. Says: Can`t parse it.
Code: Select all
INCLUDE "/usr/share/BaCon/hug_imports.bac"
'# File: /tmp/0 has the line: A = "aaa"
Set$ = "A"
Val$ = "AAA"
Cmd$ = CONCAT$("cat /tmp/0")
Cfg$ = CHOP$(EXEC$(Cmd$))
SPLIT Cfg$ BY NL$ TO Lines$ SIZE Lsize
OPEN /tmp/0 FOR WRITING AS file
FOR i = 0 TO Lsize - 1
SPLIT Lines$[i] BY " " TO Col$ SIZE size
IF Col$[0] = Set$ THEN
PRINT Col$[2], " ", Val$
IF Col$[2] != Val$ THEN
PRINT Lines$[i]
REPLACE$(Lines$[i], Col$[2], Val$)
END IF
END IF
' WRITELN Lines$[i] TO file
NEXT
CLOSE FILE file