I have a script that is used to set up a couple default widgets on a wordpress site through wp-cli.
script widgets.sh:
read -r -d '' TEXT << EOM
<strong>Line1</strong>
Address
Phone: 555-x
E-mail: so@you.say
EOM
sudo --user=$USRNAME -s wp widget add text footer-1 999 --title="Widget1" --filter="true" --visual="true" --text="$TEXT"
problem:
My problem lies in that when i call the shell script with these commands in them, such as by running
bash ~/widgets.sh
the variable $TEXT once sent to wp-cli have its linebreaks removed. If i add
echo "$TEXT"
to the script file, it echoes it with linebreaks preserved properly, which just adds to my confusion.
If i copy and paste the commands into my terminal, it preserves the linebreaks from the HEREDOC properly.
I do not understand why, but there is a lot of things i don't understand about shell scripts and bash in general, so i hope someone can enlighten me :)
Thanks in advance!