On Mon, Jun 20, 2011 at 1:12 PM, Dave Reisner <d@falconindy.com> wrote:
> Repurpose the write_list_entry function for everything we write to the
> depends and desc files by appending our own extra newline after each
> single line data point.
>
> This also refactors write_list_entry into a single printf statement.
>
> Signed-off-by: Dave Reisner <d@falconindy.com>
> ---
> More repo-add madness. Reusable code, ftw.
>
> dave
>
> *scripts/repo-add.sh.in | * 31 +++++++++++++++----------------
> *1 files changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
> index 14506dc..a23f89e 100644
> --- a/scripts/repo-add.sh.in
> +++ b/scripts/repo-add.sh.in
> @@ -88,8 +88,7 @@ There is NO WARRANTY, to the extent permitted by law.
")"
> *# * * * * * * *arg3 - File to write to
> *write_list_entry() {
> * * * *if [[ -n $2 ]]; then
> - * * * * * * * echo "%$1%" >>$3
> - * * * * * * * echo -e $2 >>$3
> + * * * * * * * printf "%%%s%%
$2
" "$1" >>"$3"
Does it make sense to use both %s and var substitution at the same
time? Why not:
printf "%%%s%%
%s
" "$1" "$2" >>"$3"