Skip to content

Commit

Permalink
Tweak FAQ answer for passing julia options in a script file. (#34018)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored Dec 9, 2019
1 parent beebfd3 commit 83d7466
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions doc/src/manual/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ When a file is run as the main script using `julia file.jl` one might want to ac
functionality like command line argument handling. A way to determine that a file is run in
this fashion is to check if `abspath(PROGRAM_FILE) == @__FILE__` is `true`.

### How do I catch CTRL-C in a script?
### [How do I catch CTRL-C in a script?](@id catch-ctrl-c)

Running a Julia script using `julia file.jl` does not throw
[`InterruptException`](@ref) when you try to terminate it with CTRL-C
Expand All @@ -90,8 +90,7 @@ use `exec` to replace the process to `julia`:
```julia
#!/bin/bash
#=
exec julia --color=yes --startup-file=no -e 'include(popfirst!(ARGS))' \
"${BASH_SOURCE[0]}" "$@"
exec julia --color=yes --startup-file=no "${BASH_SOURCE[0]}" "$@"
=#

@show ARGS # put any Julia code here
Expand All @@ -102,6 +101,19 @@ script. Julia ignores this part since it is a multi-line comment for
Julia. The Julia code after `=#` is ignored by `bash` since it stops
parsing the file once it reaches to the `exec` statement.

!!! note
In order to [catch CTRL-C](@ref catch-ctrl-c) in the script you can use
```julia
#!/bin/bash
#=
exec julia --color=yes --startup-file=no -e 'include(popfirst!(ARGS))' \
"${BASH_SOURCE[0]}" "$@"
=#

@show ARGS # put any Julia code here
```
instead. Note that with this strategy [`PROGRAM_FILE`](@ref) will not be set.

## Functions

### I passed an argument `x` to a function, modified it inside that function, but on the outside, the variable `x` is still unchanged. Why?
Expand Down

2 comments on commit 83d7466

@maleadt
Copy link
Member

@maleadt maleadt commented on 83d7466 Dec 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@maleadt
Copy link
Member

@maleadt maleadt commented on 83d7466 Dec 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your test job has completed - no new issues were detected. A full report can be found here. cc @maleadt

Please sign in to comment.