mirror of
https://github.com/zdharma-continuum/zinit-annex-patch-dl.git
synced 2026-09-10 07:26:19 -04:00
*handler: Make *file-stdout more reliable
This commit is contained in:
parent
6adc50cb58
commit
07f7ce0bb0
|
|
@ -9,11 +9,17 @@ setopt extendedglob warncreateglobal typesetsilent noshortloops
|
|||
# Downloads file to stdout. Supports following backend commands:
|
||||
# curl, wget, lftp, lynx. Used by snippet loading.
|
||||
.z-p-patch-dl-download-file-stdout() {
|
||||
local url="$1"
|
||||
local restart="$2"
|
||||
local url="$1" restart="$2"
|
||||
|
||||
if [[ "$restart" = "1" ]]; then
|
||||
path+=( "/usr/local/bin" )
|
||||
setopt localoptions localtraps
|
||||
|
||||
if (( restart )); then
|
||||
(( ${path[(I)/usr/local/bin]} )) || \
|
||||
{
|
||||
path+=( "/usr/local/bin" );
|
||||
trap "path[-1]=()" EXIT
|
||||
}
|
||||
|
||||
if (( ${+commands[curl]} )) then
|
||||
command curl -fsSL "$url" || return 1
|
||||
elif (( ${+commands[wget]} )); then
|
||||
|
|
@ -23,10 +29,8 @@ setopt extendedglob warncreateglobal typesetsilent noshortloops
|
|||
elif (( ${+commands[lynx]} )) then
|
||||
command lynx -source "$url" || return 1
|
||||
else
|
||||
[[ "${(t)path}" != *unique* ]] && path[-1]=()
|
||||
return 2
|
||||
fi
|
||||
[[ "${(t)path}" != *unique* ]] && path[-1]=()
|
||||
else
|
||||
if type curl 2>/dev/null 1>&2; then
|
||||
command curl -fsSL "$url" || return 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue