From a876890afd14304fee06dd87d7ba70412e4780d2 Mon Sep 17 00:00:00 2001 From: Samantha McVey Date: Sat, 1 Jul 2017 23:55:54 -0700 Subject: [PATCH] [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 --- modules/utility/init.zsh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index fb3de55..8e319bb 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -41,8 +41,26 @@ alias ftp='noglob ftp' alias history='noglob history' alias locate='noglob locate' alias rake='noglob rake' -alias rsync='noglob rsync' -alias scp='noglob scp' +alias rsync='noglob rsync_scp_wrap rsync' +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' # Define general aliases.