0

I have

A=123
B="abc${A}efg\n\
ijk"

if I echo $B it returns:

abc123efg
ijk

I want to pass B as the git commit message like this:

git commit -m $B

However, it does not create multiple lines and does not treat \n as a line break.

what should I do?


update:

this worked

git commit -m "$(echo -e "$B")"
7
  • Could you clarify what happened when you tried the solution in that question? Commented Oct 23, 2023 at 22:25
  • it is not a multiple lines commit message. it is one line with \n in between Commented Oct 23, 2023 at 22:26
  • Can you show us exactly what you tried? None of the commands in this question use bash's syntax for expanding escape sequences as described in the linked answer. Commented Oct 23, 2023 at 22:28
  • this one worked git commit -m "$(echo -e "$B")" Commented Oct 23, 2023 at 22:29
  • echo -e is buggy by nature -- see unix.stackexchange.com/questions/65803/…. Much more reliable to use git commit -m "$(printf '%b\n' "$B")" Commented Oct 23, 2023 at 23:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.