Пример: попытка загрузить несуществующий файл - curl -d @no-real-file http://google.com | echo $? - возвращает 0.
Как я могу заставить curl терпеть неудачу на ошибках ввода?
Пример: попытка загрузить несуществующий файл - curl -d @no-real-file http://google.com | echo $? - возвращает 0.
Как я могу заставить curl терпеть неудачу на ошибках ввода?
Вы можете использовать curl -f
-f, --fail  (HTTP) Fail silently (no output at all) on server errors. 
This is mostly done to better enable scripts etc to better deal with failed attempts. 
In normal cases when a HTTP server  fails  to  deliver  a  document,  it returns 
an HTML document stating so (which often also describes why and more). This flag 
will prevent curl from outputting that and return error 22.
This method is not fail-safe and there are occasions where non-successful response 
codes will slip through, especially when authentication is involved (response codes 
401 and 407).
Если -f используется, curl вернет 22 для следующей команды
curl -f -d @no-real-file http://google.com
Это может быть не совсем то, что вы просили, но вы можете просто сделать быструю проверку, чтобы увидеть, существует ли файл заранее:
[ -f $somefile ] && curl -d $somefile blah blah