diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2010-04-02 11:32:38 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2010-04-02 11:32:38 +0200 |
commit | f0f3c02a3ccde07d3dc79577c7eca41ea3e8e86f (patch) | |
tree | d0aaab1de872a30a94555d2da3b501e13e18c217 /etc/functions/put | |
parent | 81ac4a06bff278f07620804b7d4120342b1f6522 (diff) |
Replace $var by ${var}
Diffstat (limited to 'etc/functions/put')
-rw-r--r-- | etc/functions/put | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/etc/functions/put b/etc/functions/put index 1876852..4fe8279 100644 --- a/etc/functions/put +++ b/etc/functions/put @@ -11,7 +11,7 @@ typeset target_dir server_prefix typeset file remote_file illegal typeset -i n_hosts n_ping n_curl -if [[ -z $commands[curl] ]]; then +if [[ -z ${commands[curl]} ]]; then function curl {return 0} print -P "%B%F{yellow}curl not present, won't be able to check upload success%f%b" fi @@ -38,8 +38,8 @@ function put_becquerel () { hosts=(aneurysm_int aneurysm becquerel) hosts_nossl=(becquerel) -while [[ $1 == -* ]] { - case $1 in +while [[ ${1} == -* ]] { + case ${1} in -|--) shift; break ;; *) (( $(eval echo '$#'hosts_${1#-}) )) && eval hosts=\(\$hosts_${1#-}\) @@ -49,21 +49,21 @@ while [[ $1 == -* ]] { } -n_hosts=$#hosts -if [[ -f $1 ]] { - file=$1 - while (( $#hosts )) { +n_hosts=${#hosts} +if [[ -f ${1} ]] { + file=${1} + while (( ${#hosts} )) { remote_file=${file:t} - put_$hosts[1] - ping -c 1 $hostname &> /dev/null || ping6 -c 1 $hostname &> /dev/null + put_${hosts[1]} + ping -c 1 ${hostname} &> /dev/null || ping6 -c 1 ${hostname} &> /dev/null if (( ? == 0 )) { - if [[ $remote_file == ${~illegal} ]] { + if [[ ${remote_file} == ${~illegal} ]] { remote_file=${remote_file:r} } - scp $ssh_options $file $hostname:$target_dir/$remote_file - ssh $ssh_options $hostname "chmod 644 $target_dir$remote_file" - if $(curl -fI $server_prefix$remote_file &> /dev/null); then - echo $server_prefix$remote_file + scp ${ssh_options} ${file} ${hostname}:${target_dir}/${remote_file} + ssh ${ssh_options} ${hostname} "chmod 644 ${target_dir}${remote_file}" + if $(curl -fI ${server_prefix}${remote_file} &> /dev/null); then + echo ${server_prefix}${remote_file} return 0 else (( n_curl++ )) @@ -73,11 +73,11 @@ if [[ -f $1 ]] { } shift hosts } - echo "Tried uploading to $n_hosts hosts without success" >&2 - ((n_ping)) && echo " - $n_ping hosts are unreachable" >&2 - ((n_curl)) && echo " - $n_curl errors while uploading" >&2 + echo "Tried uploading to ${n_hosts} hosts without success" >&2 + ((n_ping)) && echo " - ${n_ping} hosts are unreachable" >&2 + ((n_curl)) && echo " - ${n_curl} errors while uploading" >&2 return 1 } else { - echo "$1: No such file" + echo "${1}: No such file" return 1 } |