Skip to main content
3 of 3
replaced http://stackoverflow.com/ with https://stackoverflow.com/

The problem you have has nothing to do with echo -e or your log() function. The problem is with apostrophes:

log this is a testing's post

The shell (bash, in your case) has special meanings for certain characters. Apostrophes (single quotes) are used to quote entire strings, and prevent most other kinds of interpolation. bash expects them to come in pairs, which is why you get the extra prompt lines until you type the second one. If you want a literal single quote in your string, you need to tell bash, by escaping it via \', like so:

log this is a testing\'s post

Again, log is beside the point. You can try this out with plain old echo if you like:

echo this is a testing\'s post

See Which characters need to be escaped in bash for more info.

type_outcast
  • 1.3k
  • 8
  • 16