shell - Prepend printed string with its final newlines to a bash variable -


i have following function defined in bash:

function print_revision {     printf "revision %s (%s)\n%s\n\n" "$1" "$(date --utc +%d.%m.%y,\ %h:%m\ utc)" \     "----------------------------------------" } 

i have variable, $changes text in it. need prepend string printed in print_revision $changes variable.

i've tried following doesn't seem work:

changes="$(print_revision $current_short_revision)"$changes 

it prepends print_revision goes through last 2 newline characters, concatenating contents of $changes right after ----- part.

how can achieve need?

the simplest fix print current value of $changes inside command substitution:

changes="$(print_revision $current_short_revision; echo "$changes")" 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -