TABLE OF CONTENTS


::pwtk::eval_in_dir

SYNOPSIS

proc ::pwtk::eval_in_dir {dir script} {

PURPOSE

Evaluate a script in directory $dir. If $dir does not exist, it is created. This command is equivalent to:

       set here [pwd]
       file mkdir $dir
       cd $dir
       eval $script
       cd $here

ARGUMENTS

RETURN VALUE

The return value of the last command in the script.

SOURCE

    set here [pwd]
    try {
        file mkdir $dir
        cd $dir
        pwtk::print "from [procName]:\nCWD changed to [pwd]\n"
    } on error err {
        ::pwtk::error "cannot create directory: $dir\n\n$err" 1
    }
    set code [catch {uplevel 1 $script} result]
    cd $here
    pwtk::print "from [procName]:\nCWD reverted to [pwd]\n"
    
    return -code $code $result
}