aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-09-04 23:55:01 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2016-09-04 23:55:01 +0300
commit29ebe894780dd5384bef00af34b81eecb01343e9 (patch)
tree864794a9a17c812560e1bed50c8ff52c0f3142be
parent9cc2ffffedd74917bb1a26adf26afc3a4c130c8f (diff)
downloadrex-29ebe894780dd5384bef00af34b81eecb01343e9.tar.gz
rex-29ebe894780dd5384bef00af34b81eecb01343e9.tar.bz2
Use {*} where appropriate; fix rex --cp
-rwxr-xr-xrex.exp31
-rw-r--r--rex.man826
2 files changed, 32 insertions, 25 deletions
diff --git a/rex.exp b/rex.exp
index 4229942..9c50c08 100755
--- a/rex.exp
+++ b/rex.exp
@@ -83,7 +83,7 @@ namespace eval pmres {
}
if {$mode == "-ip"} {
if {[lindex $rec 0] == $arg} {
- eval lappend res [lrange $rec 1 end]
+ lappend res {*}[lrange $rec 1 end]
}
} else {
if {[lsearch -exact [lrange $rec 1 end] $arg] != -1} {
@@ -397,7 +397,7 @@ proc getans {args} {
} else {
set noecho 0
}
- puts -nonewline [eval concat $args]
+ puts -nonewline {*}$args
puts -nonewline " "
flush stdout
if {$noecho} {
@@ -416,7 +416,7 @@ proc getans {args} {
# if the user replied Y (or <CR>), and false otherwise.
proc getyn {args} {
lappend args { [Y/n]?}
- switch -glob [string trimleft [getans [eval concat $args]] " \t"] {
+ switch -glob [string trimleft [getans {*}$args] " \t"] {
"[yY]*" -
"" { return 1 }
default { return 0 }
@@ -966,7 +966,7 @@ proc runcp {args} {
foreach host $hosts {
set cmd $cmd_stub
lappend cmd [hostuser $host]@$host:[lindex $args end]
- eval spawn -noecho scp $cmd
+ spawn -noecho scp {*}$cmd
lappend sidlist $spawn_id
set sidinfo($spawn_id,host) $host
set sidinfo($spawn_id,cmd) $cmd
@@ -1262,7 +1262,7 @@ proc runcmd {hosts command} {
set cmd $config(data)
lappend cmd "[hostuser $host]@$host:$sidinfo($sid,wd)"
debug 3 "$sid: starting scp $cmd"
- eval spawn -noecho scp $cmd
+ spawn -noecho scp {*}$cmd
lappend sidlist $spawn_id
set sidinfo($spawn_id,state) COPY
set sidinfo($spawn_id,host) $host
@@ -1450,7 +1450,7 @@ getopt -progname $argv0 -longopts $longopts $argc $argv $shortopts {
e { set config(option,encrypt) 1 }
f { set config(option,copy) 2 }
g { set config(option,hostgroup) $optarg }
- H { eval lappend config(hosts) [split $optarg ","] }
+ H { lappend config(hosts) {*}[split $optarg ","] }
h prusage
l { set config(option,log) 1 }
I { set config(option,interactive) 1 }
@@ -1464,7 +1464,7 @@ getopt -progname $argv0 -longopts $longopts $argc $argv $shortopts {
s { set config(script) 1 }
u { set config(user) $optarg }
N { set config(option,noop) 1 }
- X { eval lappend config(exclude_hosts) [split $optarg ","] }
+ X { lappend config(exclude_hosts) {*}[split $optarg ","] }
V prversion
w { set config(option,confirm) 1 }
Z { set config(option,zsh-quirk) 1 }
@@ -1626,7 +1626,7 @@ if {$config::initialized} {
if {$var == "hosts" &&
![info exists config(option,ignore-hosts)]} {
set hosts [::config::cfgvar hosts]
- eval lappend hosts $config(hosts)
+ lappend hosts {*}$config(hosts)
set config(hosts) $hosts
debug 3 "config(hosts) = $config(hosts)"
}
@@ -1752,14 +1752,17 @@ if {![config_option copy]} {
if [config_option script] {
lappend config(data) $config(progname)
}
+
+ # FIXME: Catch conflicting options (--script et al.)
+ if {$config(progname) == "shell" && [llength $config(argv)] == 2} {
+ lappend config(hosts) [lindex $config(argv) 1]
+ set config(option,shell) 1
+ }
} elseif {[config_option copy] == 2} {
- exit [eval runcprev $config(argv)]
+ exit [runcprev {*}$config(argv)]
}
-if {$config(progname) == "shell" && [llength $config(argv)] == 2} {
- lappend config(hosts) [lindex $config(argv) 1]
- set config(option,shell) 1
-} elseif {![info exists config(hosts)] || [llength $config(hosts)] == 0} {
+if {![info exists config(hosts)] || [llength $config(hosts)] == 0} {
terror "no host list"
listgroups
exit 1
@@ -1875,7 +1878,7 @@ while {[llength $config(hosts)] > 0} {
}
if [config_option copy] {
- eval runcp $bunch $config(command)
+ runcp $bunch {*}$config(argv)
} else {
runcmd $bunch [remote_command]
}
diff --git a/rex.man8 b/rex.man8
index 5940494..2a158c0 100644
--- a/rex.man8
+++ b/rex.man8
@@ -13,7 +13,7 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with Rex. If not, see <http://www.gnu.org/licenses/>.
-.TH REX 8 "September 2, 2016" "REX" "Rex User Reference"
+.TH REX 8 "September 4, 2016" "REX" "Rex User Reference"
.ds ET /etc
.SH NAME
rex \- remote execution utility
@@ -79,14 +79,14 @@ There are two ways of specifying hostnames to operate upon.
.PP
First, the \fB\-H\fR (\fB\-\-host\fR) option adds its argument (which
must be a hostname or IP address) to the list of hosts. To construct
-a list of several hosts, use as many \fB\-H\fR options as necessary.
+a list on several hosts, use as many \fB\-H\fR options as necessary.
.PP
This option exists mainly as a way of quickly running a job of several
hosts at once. If you have a set of hosts which you often work with,
it's best to use a
.IR hostgroup .
.PP
-A \fIhostgroup\fR defines a list of hosts and optionally associates
+A \fIhostgroup\fR defines a list of hosts and, optionally,
a set of
.B rex
settings to use when running commands on them. Each hostgroup is
@@ -135,9 +135,13 @@ unset, \fBEDITOR\fR) environment variable. Upon exit from the editor,
it compares the new content with the existing one. If changed, the
user is prompted whether they wish to save the changes.
.PP
-The database consists of \fIkey-value\fR pairs. The key part can
-be qualified by prefixing with the hostname and/or group name. I.e.,
-using square brackets to denote optional parts, the key structure is:
+The database is a dictionary of \fIkey-value\fR pairs. A key
+identifies the credential (e.g. \fBuser\fR, for username, or
+\fBpass\fR, for password). Unless prefixed with one or more
+\fIquaifiers\fR, it is valid for all servers in all hostgroups.
+Qualifiers limit the scope of a key to a given hostgroup or server.
+.PP
+In general, the syntax for a key is:
.PP
.EX
[\fIGROUP\fB:\fR][\fIHOST\fB:\fR]\fIKEYWORD\fR
@@ -157,9 +161,9 @@ The order of lookup is as follows:
.RE
.PP
For example, to determine the login name for the given host, \fBrex\fR
-looks up for the keyword \fBuser\fR. If not found and the the
-\fB\-u\fR (\fB\-\-user\fR) option is given, its value is used.
-Otherwise, the name of the value of the environment variable
+looks up for the keyword \fBuser\fR. If no matching key is found
+and the the \fB\-u\fR (\fB\-\-user\fR) option is given, its value is
+used. Otherwise, the name of the value of the environment variable
.B USER
is used.
.PP
@@ -214,8 +218,8 @@ use the \fB\-S\fR (\fB\-\-script\fR) option. With this option,
\fICOMMAND\fR is first transferred to a temporary directory on the
remote machine and then executed there with the supplied arguments.
.SS Configuration files
-Upon startup \fBrex\fR looks for the following files and loads them
-in that order:
+Upon startup \fBrex\fR looks for the following files and attempts to
+source them:
.TP
.B \*(ET/rex/rc
System-wide configuration file.

Return to:

Send suggestions and report system problems to the System administrator.