Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/frontend/cast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,9 @@ end
function codegen_script_entry(m::Module, line, @nospecialize(ex))
quote
$(codegen_create_entry(m, line, ex))
command_main()
if abspath(PROGRAM_FILE) == @__FILE__
command_main()
end
end
end

Expand Down
6 changes: 4 additions & 2 deletions test/scripts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ using Test
@testset "scripts" begin
empty!(ARGS)
push!(ARGS, "arg", "--opt1=2", "--opt2", "3", "-f")
@test Base.include(Main, "scripts/hello.jl") == 0
Base.include(Main, "scripts/hello.jl")
@test Main.command_main() == 0

empty!(ARGS)
push!(ARGS, "activate", "-h")
Expand All @@ -17,7 +18,8 @@ using Test

empty!(ARGS)
push!(ARGS, "Author - Year.pdf")
@test Base.include(Main, "scripts/searchpdf.jl") == 0
Base.include(Main, "scripts/searchpdf.jl")
@test Main.command_main() == 0
end

end