Browse Source

[utility] scp/rsync glob local paths but don't glob remote paths

Adds a function which wraps rsync and scp so that remote paths are not globbed
but local paths are globbed. This is because the programs have their own
globbing for remote paths. The wrap function globs args starting in / and ./
and doesn't glob paths with : in it as these are interpreted as remote paths
by these programs unless the path starts with / or ./

Fixes issue #1125
master
Samantha McVey 8 years ago committed by Kaleb Elwert
parent
commit
a876890afd
  1. 22
      modules/utility/init.zsh

22
modules/utility/init.zsh

@ -41,8 +41,26 @@ alias ftp='noglob ftp'
alias history='noglob history' alias history='noglob history'
alias locate='noglob locate' alias locate='noglob locate'
alias rake='noglob rake' alias rake='noglob rake'
alias rsync='noglob rsync' alias rsync='noglob rsync_scp_wrap rsync'
alias scp='noglob scp' alias scp='noglob rsync_scp_wrap scp'
# This function wraps rsync and scp so that remote paths are not globbed
# but local paths are globbed. This is because the programs have their own
# globbing for remote paths. The wrap function globs args starting in / and ./
# and doesn't glob paths with : in it as these are interpreted as remote paths
# by these programs unless the path starts with / or ./
function rsync_scp_wrap {
local args=( )
local cmd="$1"
shift
local i
for i in "$@"; do case $i in
( ./* ) args+=( ${~i} ) ;; # glob
( /* ) args+=( ${~i} ) ;; # glob
( *:* ) args+=( ${i} ) ;; # noglob
( * ) args+=( ${~i} ) ;; # glob
esac; done
command $cmd "${(@)args}"
}
alias sftp='noglob sftp' alias sftp='noglob sftp'
# Define general aliases. # Define general aliases.

Loading…
Cancel
Save