Wrongly closed question


#1

Hy,

I believe this topic (Send a new line in a comment to Conduit API from Jenkins) was erroneously closed. But now I can’t comment and don’t know how to contact the administrator. What can I do?

Regarding the factual topic, this is a different question from Send a new line in a comment to Conduit API.

I started both and would in fact continue this discussion in the first, but was already closed as well. In 2225 I was trying to send a “new line”, from the command line, which got the correct answer that in cli “new line” is textual new line.

However, when I invoke curl from inside Jenkins build (topic 2259), this invocation is made throw a string, which cannot have multiple lines (in the sense the command line has), as most programming languages don’t support textual new lines inside a string variable.

Thanks


#2

This looks more like a standard bash question than specifically a Phabricator question.

Off the top of my head (and having tested via a terminal just now), there are 2 options here.

  1. Set your bash variable to the output from a call to a sub shell eg:
    message=$(echo -e "test\ntest")

  2. insert the newline character inside a dollar followed by single quotes, eg:
    message="test"$'\n'"test"


#3

Ok, I see. I thought there would be some “markup” to signal a new line, but I should instead send it from bash.
That worked. Thanks!


#4

If you wanted to include the new line characters in the conduit call itself (as suppose to including a bash variable) then using $'\n' notation within curl the command might work eg:
curl https://review.feedzai.com/api/differential.createcomment -d api.token="api.token" -d revision_id=$PHABRICATOR_ID -d message="Test"$'\n'"Test"


#5

That doesn’t work. What were you trying to do?
I mean, the $ plus a literal \n is suppose to have a special meaning?


#6
$ echo a$'\n'$'\n'b
a

b

Basic questions like how to escape newlines in a particular language are better suited to a general programming community like StackOverflow, or by reading the documentation for your shell / language / application. Nothing about your problem is specific to Phabricator.


#7