Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions acme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1852,9 +1852,14 @@ _inithttp() {
_ACME_CURL="$_ACME_CURL --cacert $CA_BUNDLE "
fi

if _contains "$(curl --help 2>&1)" "--globoff"; then
if _contains "$(curl --help 2>&1)" "--globoff" || _contains "$(curl --help curl 2>&1)" "--globoff"; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Neilpang 你看这样行了吗,先按旧版的help判断,如果找不到再按新版判断

_ACME_CURL="$_ACME_CURL -g "
fi

#from curl 7.76: return fail on HTTP errors but keep the body
if _contains "$(curl --help http 2>&1)" "--fail-with-body"; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是不是也需要改成 2次判断.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里完全是一个新特性,所以没有向后兼容的需求。
而且,curl 是从7.73出现的--help <category>这个特性,而curl 7.76才出现的--fail-with-body参数。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ACME_CURL="$_ACME_CURL --fail-with-body "
fi
fi

if [ -z "$_ACME_WGET" ] && _exists "wget"; then
Expand All @@ -1872,11 +1877,11 @@ _inithttp() {
elif [ "$CA_BUNDLE" ]; then
_ACME_WGET="$_ACME_WGET --ca-certificate=$CA_BUNDLE "
fi
fi

#from wget 1.14: do not skip body on 404 error
if [ "$_ACME_WGET" ] && _contains "$($_ACME_WGET --help 2>&1)" "--content-on-error"; then
_ACME_WGET="$_ACME_WGET --content-on-error "
#from wget 1.14: do not skip body on 404 error
if _contains "$(wget --help 2>&1)" "--content-on-error"; then
_ACME_WGET="$_ACME_WGET --content-on-error "
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these codes from outer into the wget initialization blocks.
So it doesn't need to duplicate evaluate $_ACME_WGET, and the --help does not need the other arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改动其实没有必要. 如果 已经初始化过了,__HTTP_INITIALIZED=1, 根本就不会再次走进来.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改动确实没有必要性,只是为了改善可读性,使代码结构更清晰一些。用伪代码表示一下改动前的代码是:

if 使用curl
  初始化curl
  if curl 支持某个特性
    初始化特性
  fi
fi
if 使用wget
  初始化wget
fi
if 使用wget 且 支持某个特性
  初始化特性
fi

这个代码结构看着很混乱,curl的所有初始化被放在了if 使用curl这个if块里,但是wget的分成了两块。
所以我希望把它改到if 使用wget里面去,改善可读性。

fi

__HTTP_INITIALIZED=1
Expand Down