by mateuszf · 12y ago · 0 comments
cat <<REQUEST_BODY |
{
"from" : 0,
"size" : 40
}
REQUEST_BODY
curl http://localhost -d @-
It allows to pass heredoc text to standard input of next command. curl http://localhost -d @- <<REQUEST_BODY
{
"from" : 0,
"size" : 40
}
REQUEST_BODY request_body() {
cat <<REQUEST_BODY |
{
"from" : 0,
"size" : 40
}
REQUEST_BODY
}
get_url() {
curl http://localhost -d @-
}
request_body | get_url
I find it helps readability when you come back to it a year later. Of course, it's also easy to parameterize the body, if needed./readability sometimes trumps YAGNI
cat <<REQUEST_BODY | curl http://localhost -d @-
{
"from" : 0,
"size" : 40
}
REQUEST_BODY