linux - Expect/TCL simple proc/variable issue -


i have expect script works have attempted remove duplicate code , use proc string passed proc not seem getting used.

as first exposure tcl/expect basic variable passing/usage.

i had (worked):

    expect {         "condition" {}         timeout { various cleanup operations; send_user "a message"; exit 1 }     } 

and changed (broken):

    proc exit_on_error {message} {         various cleanup operations         send_user "$message"         exit 1     }     expect {         "condition" {}         timeout { exit_on_error "a message" }     } 

it cleanup operations , exits send_user seems have empty string

    send_user $message 

complains wrong number of arguments.

bash expanding $message variable in here-doc before sending doc expect.

if not rely on using shell variables in expect script, single quote here-doc:

expect <<-'done' 

otherwise, choose 1 of these options protect tcl variable expansion shell:

send_user \$message send_user [set message] 

tcl not require quote variable: expands variable maintains value single word.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -