REBOL [
    System: "REBOL [R3] Language Interpreter and Run-time Environment"
    Title: "REBOL 3 Mezzanine: Control"
    Rights: {
        Copyright 2012 REBOL Technologies
        REBOL is a trademark of REBOL Technologies
    }
    License: {
        Licensed under the Apache License, Version 2.0
        See: http://www.apache.org/licenses/LICENSE-2.0
    }
]

launch: func [
    {Runs a script as a separate process; return immediately.}
    script [file! string! none!] "The name of the script"
    /args arg [string! block! none!] "Arguments to the script"
    /wait "Wait for the process to terminate"
][
    if file? script [script: to-local-file clean-path script]
    args: reduce [to-local-file system/options/boot script]
    if arg [append args arg]
    either wait [call/wait args] [call args]
]

wrap: func [
    "Evaluates a block, wrapping all set-words as locals."
    body [block!] "Block to evaluate"
][
    do bind/copy/set body make object! 0
]

check-set: func [
    "Set optional value via set-word or set-path, TRUE unless UNSET!"

    'target [set-word! set-path!]
    value [unset! any-value!]
][
    any-value? set/opt target :value
]

REBOL [
    System: "REBOL [R3] Language Interpreter and Run-time Environment"
    Title: "REBOL 3 Mezzanine: Control"
    Rights: {
        Copyright 2012 REBOL Technologies
        REBOL is a trademark of REBOL Technologies
    }
    License: {
        Licensed under the Apache License, Version 2.0
        See: http://www.apache.org/licenses/LICENSE-2.0
    }
]

launch: func [
    {Runs a script as a separate process; return immediately.}
    script [file! string! none!] "The name of the script"
    /args arg [string! block! none!] "Arguments to the script"
    /wait "Wait for the process to terminate"
][
    if file? script [script: to-local-file clean-path script]
    args: reduce [to-local-file system/options/boot script]
    unless unset? :arg [append args arg]
    either wait [call/wait args] [call args]
]

wrap: func [
    "Evaluates a block, wrapping all set-words as locals."
    body [block!] "Block to evaluate"
][
    do bind/copy/set body make object! 0
]

check-set: func [
    "Set optional value via set-word or set-path, TRUE unless UNSET!"

    'target [set-word! set-path!]
    value [unset! any-value!]
][
    any-value? set/opt target :value
]

Correct LAUNCH for unset refinement args
Correct LAUNCH for unset refinement args

The LAUNCH command is miserly with its arguments and uses a FUNC and
not a FUNCTION, so it reuses the refinement ARGS assuming it can just
test ARG.  It can do that, but now it has to test for unset.
