Skip to content

Commit

Permalink
Don't force shebang line in amalgamated script.
Browse files Browse the repository at this point in the history
There may be Lua implementations that don't support shebang lines in
files or situations where you want to load amalgamated Lua code from
somewhere other than a file.
  • Loading branch information
siffiejoe committed Oct 18, 2017
1 parent 637c0d8 commit 187ba89
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/amalg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -395,17 +395,18 @@ local function amalgamate( ... )
out = assert( io.open( oname, "w" ) )
end

-- If a main script is to be embedded, this includes a shebang line
-- so that the resulting amalgamation can be run without explicitly
-- specifying the interpreter on unixoid systems.
-- If a main script is to be embedded, this includes the same
-- shebang line that was used in the main script, so that the
-- resulting amalgamation can be run without explicitly
-- specifying the interpreter on unixoid systems (if a shebang
-- line was specified in the first place, that is).
local script_bytes, script_binary, shebang
if script then
script_bytes, script_binary, shebang = readluafile( script )
if shebang then
out:write( shebang, "\n\ndo\n\n" )
else
out:write( "#!/usr/bin/env lua\n\ndo\n\n" )
out:write( shebang, "\n\n" )
end
out:write( "do\n\n" )
end

-- Sort modules alphabetically. Modules will be embedded in
Expand Down

0 comments on commit 187ba89

Please sign in to comment.