diff options
author | Marc Cornellà <hello@mcornella.com> | 2021-08-10 21:09:21 +0200 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2021-08-10 21:09:21 +0200 |
commit | 7eeb1e193d4a55ab706931fb80ef556a939be8fd (patch) | |
tree | fef860bafbc96b7ecaa87b8ed13412d3161209a0 /lib/functions.zsh | |
parent | c24928815179e1a8e1e3a0a4ab130e22ba2e0f1a (diff) | |
download | zsh-7eeb1e193d4a55ab706931fb80ef556a939be8fd.tar.gz zsh-7eeb1e193d4a55ab706931fb80ef556a939be8fd.tar.bz2 zsh-7eeb1e193d4a55ab706931fb80ef556a939be8fd.zip |
refactor(lib): refactor take functions
Diffstat (limited to 'lib/functions.zsh')
-rw-r--r-- | lib/functions.zsh | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/functions.zsh b/lib/functions.zsh index 24b7254fb..73b491a59 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -41,26 +41,27 @@ function mkcd takedir() { } function takeurl() { - data=$(mktemp) - curl -L $1 > $data - tar xf $data - thedir=$(tar tf $data | head -1) - rm $data - cd $thedir + local data thedir + data="$(mktemp)" + curl -L "$1" > "$data" + tar xf "$data" + thedir="$(tar tf "$data" | head -1)" + rm "$data" + cd "$thedir" } function takegit() { - git clone $1 - cd $(basename ${1%%.git}) + git clone "$1" + cd "$(basename ${1%%.git})" } function take() { if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then - takeurl $1 + takeurl "$1" elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then - takegit $1 + takegit "$1" else - takedir $1 + takedir "$@" fi } |