diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-09-24 11:41:09 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-09-24 11:41:09 +0300 |
commit | c63c34d0a9f8ad48d59e24c87f0ed90fe6026894 (patch) | |
tree | 7f6e75575129a85459904670d25338dd3943c35c | |
parent | c8798123615a266d30d7a53664e73195c8304f9d (diff) | |
download | rex-c63c34d0a9f8ad48d59e24c87f0ed90fe6026894.tar.gz rex-c63c34d0a9f8ad48d59e24c87f0ed90fe6026894.tar.bz2 |
Bugfixes
* rex (::getopt::parse): Initialize group_id and group_def
Don't use dict lappend
(add_host_key_list): Catch eventual errors
(rex_command,rex_copy_to,rex_list): Move --ignore-hosts to group
global
-rwxr-xr-x | rex | 65 |
1 files changed, 40 insertions, 25 deletions
@@ -860,6 +860,8 @@ namespace eval ::getopt { proc parse {args} { # puts "ARGS [llength $args] $args" + set group_id {} + set group_def {} while {[llength $args] > 0} { set arg [lindex $args 0] switch -- $arg { @@ -1000,8 +1002,13 @@ namespace eval ::getopt { lappend select $repr [subst -nocommand { upvar 1 parsedict parser set lambda {{optchar optarg} {$cmd}} - set item [list \$lambda \$optchar \$optarg] - dict lappend parser code $group_name [list \$item] + if {[dict exists \$parser code $group_name]} { + set lst [dict get \$parser code $group_name] + } else { + set lst {} + } + lappend lst [list \$lambda \$optchar \$optarg] + dict set parser code $group_name \$lst }] } @@ -1054,6 +1061,7 @@ namespace eval ::getopt { proc run {d id} { global config if {[dict exists $d code $id]} { + # puts "[llength [dict get $d code $id]]" foreach item [dict get $d code $id] { # Each list element is: {lambda optchar optarg} # FIXME @@ -1695,11 +1703,23 @@ proc add_host_key_list {batchvar sid key confval} { upvar $batchvar batch if {[rexdbget -return val -host [job get $batch $sid host] $key]} { - job lappend batch $sid $key {*}$val + if {[catch {job lappend batch $sid $key {*}$val} result options]} { + if {[config_option tcl-trace]} { + return -code error -options $options + } + terror "failed to save value: $key=$val: $result" + terror "value obtained from rexdb for host [job get $batch $sid host]" + } return } if {[info exist config($confval)]} { - job lappend batch $sid $key {*}$config($confval) + if {[catch {job lappend batch $sid $key {*}$config($confval)} result options]} { + if {[config_option tcl-trace]} { + return -code error -options $options + } + terror "failed to save value: $key=$val: $result" + terror "value obtained from rc" + } } } @@ -1713,13 +1733,13 @@ namespace eval ::description { } } - # if {![info exists retval]} { - # set filename "$group/rc" - # catch { - # source $filename - # set retval $description - # } - # } + if {![info exists retval]} { + set filename "$group/rc" + catch { + source $filename + set retval $description + } + } if {[info exists retval]} { return $retval } @@ -2459,7 +2479,6 @@ namespace eval ::config { }} user {var { return "user $var" }} password {var { return "password $var" }} - command {var { return "command $var"}} } proc host {args} { @@ -2592,10 +2611,6 @@ namespace eval ::config { proc password {text} { set ::config(pass) [::passenc $text] } - - proc command {args} { - set ::config(argv) $args - } proc read {file} { variable cfgvars @@ -2992,6 +3007,9 @@ proc rex_command args { group,g=NAME {select host group} { option_set group $optarg } + ignore-hosts,i + {ignore the list of hosts read from the hostgroup file} + { option_set ignore-hosts true } } \ -group mode { buffer-output,b @@ -3012,9 +3030,6 @@ proc rex_command args { exclude-host,X=HOST {remove HOST from the host list} { lappend ::config(exclude_hosts) {*}[split $optarg ","] } - ignore-hosts,i - {ignore the list of hosts read from the hostgroup file} - { option_set ignore-hosts true } interactive,I {interactively ask for missing usernames and passwords} { option_set interactive true } @@ -3172,6 +3187,9 @@ the OPTIONS (at least one must be given).} \ group,g=NAME {select host group} { option_set group $optarg } + ignore-hosts,i + {ignore the list of hosts read from the hostgroup file} + { option_set ignore-hosts true } } \ -group mode { host,H=HOST @@ -3180,9 +3198,6 @@ the OPTIONS (at least one must be given).} \ exclude-host,X=HOST {remove HOST from the host list} { lappend ::config(exclude_hosts) {*}[split $optarg ","] } - ignore-hosts,i - {ignore the list of hosts read from the hostgroup file} - { option_set ignore-hosts true } } switch -- $argc { @@ -3266,6 +3281,9 @@ proc rex_copy_to {} { group,g=NAME {select host group} { option_set group $optarg } + ignore-hosts,i + {ignore the list of hosts read from the hostgroup file} + { option_set ignore-hosts true } } \ -group mode { confirm,w @@ -3277,9 +3295,6 @@ proc rex_copy_to {} { exclude-host,X=HOST {remove HOST from the host list} { lappend ::config(exclude_hosts) {*}[split $optarg ","] } - ignore-hosts,i - {ignore the list of hosts read from the hostgroup file} - { option_set ignore-hosts true } interactive,I {interactively ask for missing usernames and passwords} { option_set interactive true } |