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
Post a Comment