Improved handling of hash bang.
h3rald h3rald@h3rald.com
Wed, 03 Jun 2026 10:55:45 +0200
2 files changed,
8 insertions(+),
10 deletions(-)
M
min.nim
→
min.nim
@@ -109,19 +109,16 @@
proc minStr*(buffer: string) = minStream(newStringStream(buffer), "input") -proc minFile*(fn: string, op = "interpret", main = true): seq[ - string] {.discardable.} = - var fileLines = newSeq[string](0) - var contents = "" +proc minFile*(fn: string, op = "interpret", main = true): seq[string] {.discardable.} = + var contents: string try: - fileLines = fn.readFile().splitLines() + contents = fn.readFile() except CatchableError: logging.fatal("Cannot read from file: " & fn) terminate(3) - if fileLines[0].len >= 2 and fileLines[0][0..1] == "#!": - contents = ";;\n" & fileLines[1..fileLines.len-1].join("\n") - else: - contents = fileLines.join("\n") + if contents.len >= 2 and contents[0] == '#' and contents[1] == '!': + contents[0] = ';' + contents[1] = ';' minStream(newStringStream(contents), fn, op, main) when isMainModule:
M
next-release.md
→
next-release.md
@@ -4,11 +4,12 @@ * By default, nimble builds are no longer statically linking other libraries.
### Fixes and Improvements -* Ensure the relevant procs are gcsafe. +* Ensured that all the relevant procs are gcsafe. * No longer using ref for `MinValue` objects. * No longer performing a deep copy when dequoting. * Optimized the way debug information is stored to reduce memory usage. * Avoiding creating unnecessary scopes when possible (withScope macro already creates a scope). * Fixed `setSigil` incorrectly calling `setSymbol`. +* Improved handling of hash bang.