~ubuntu-branches/ubuntu/wily/julia/wily

« back to all changes in this revision

Viewing changes to base/client.jl

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2013-11-17 19:32:52 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20131117193252-tkrpclguqqebqa35
Tags: 0.2.0+dfsg-3
testsuite-i386.patch: loosen the numerical precision for yet another test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
end
46
46
 
47
47
function repl_cmd(cmd)
48
 
    shell = get(ENV,"SHELL","/bin/sh")
 
48
    shell = shell_split(get(ENV,"JULIA_SHELL",get(ENV,"SHELL","/bin/sh")))
49
49
    if isempty(cmd.exec)
50
50
        error("no cmd to execute")
51
51
    elseif cmd.exec[1] == "cd"
59
59
        end
60
60
        println(pwd())
61
61
    else
62
 
        run(@windows? cmd : detach(`$shell -i -c "$(shell_escape(cmd))"`))
 
62
        run(@windows? cmd : `$shell -i -c "($(shell_escape(cmd))) && true"`)
63
63
    end
64
64
    nothing
65
65
end
107
107
            else
108
108
                ast = expand(ast)
109
109
                value = eval(Main,ast)
110
 
                global ans = value
 
110
                eval(Main, :(ans = $(Expr(:quote, value))))
111
111
                if !is(value,nothing) && show_value
112
112
                    if have_color
113
113
                        print(answer_color())
136
136
    isa(STDIN,TTY) && println()
137
137
end
138
138
 
139
 
function readBuffer(stream::AsyncStream, nread)
 
139
function read_buffer(stream::AsyncStream, nread)
140
140
    global _repl_enough_stdin::Bool
141
141
    while !_repl_enough_stdin && nb_available(stream.buffer) > 0
142
142
        nread = int(search(stream.buffer,'\n')) # never more than one line or readline explodes :O
155
155
        ptr = pointer(stream.buffer.data,stream.buffer.ptr)
156
156
        skip(stream.buffer,nread)
157
157
        #println(STDERR,stream.buffer.data[stream.buffer.ptr-nread:stream.buffer.ptr-1])
158
 
        ccall(:jl_readBuffer,Void,(Ptr{Void},Cssize_t),ptr,nread)
 
158
        ccall(:jl_read_buffer,Void,(Ptr{Void},Cssize_t),ptr,nread)
159
159
    end
160
160
    return false
161
161
end
177
177
        end
178
178
        ccall(:repl_callback_enable, Void, (Ptr{Uint8},), prompt_string)
179
179
        global _repl_enough_stdin = false
180
 
        start_reading(STDIN, readBuffer)
 
180
        start_reading(STDIN, read_buffer)
181
181
        (ast, show_value) = take(repl_channel)
182
182
        if show_value == -1
183
183
            # exit flag
216
216
end
217
217
 
218
218
# try to include() a file, ignoring if not found
219
 
function try_include(f::String)
220
 
    if is_file_readable(f)
221
 
        include(f)
222
 
    end
223
 
end
 
219
try_include(path::String) = isfile(path) && include(path)
224
220
 
225
221
function process_options(args::Array{Any,1})
226
222
    global ARGS, bind_addr
350
346
end
351
347
 
352
348
function load_juliarc()
353
 
    try_include(abspath("/etc","julia","juliarc.jl"))
354
 
    try_include(abspath(user_prefdir(),".juliarc.jl"))
 
349
    # If the user built us with a specifi Base.SYSCONFDIR, check that location first for a juliarc.jl file
 
350
    #   If it is not found, then continue on to the relative path based on JULIA_HOME
 
351
    if !isempty(Base.SYSCONFDIR) && isfile(joinpath(Base.SYSCONFDIR,"julia","juliarc.jl"))
 
352
        include(abspath(Base.SYSCONFDIR,"julia","juliarc.jl"))
 
353
    else
 
354
        try_include(abspath(JULIA_HOME,"..","etc","julia","juliarc.jl"))
 
355
    end
 
356
    try_include(abspath(homedir(),".juliarc.jl"))
355
357
end
356
358
 
357
359