如何解釋curl超時?

如何解釋curl超時?
curl --max-time 3 'http://website.com';
  if [ 0 -eq $? ]; then 
    ...
  else
    ...
  fi

我試圖讓curl 對超時的URL 做出不同的回應。如何將curl失敗的輸出傳遞到if語句中?這根本行不通:

https://unix.stackexchange.com/questions/124918/how-to-check-whether-a-command-such-as-curl-completed-without-error

答案1

curl退出代碼( 的值$?)記錄在其線上說明頁面中。退出代碼 28 對應於“操作超時。依條件已達到規定的超時期限。

相關內容