[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf $variable inside initial parenthesis or use %s?
From: |
David |
Subject: |
Re: printf $variable inside initial parenthesis or use %s? |
Date: |
Wed, 11 Jan 2023 19:28:13 +1100 |
On Wed, 11 Jan 2023 at 19:00, Roger <rogerx.oss@gmail.com> wrote:
>
> When using builtin bash printf, which is more appropriate?
>
> printf "$var"
>
> or
>
> printf "%s" $var
>
> (Disregarding proper variable quoting syntax for ensuring proper variable
> expansion.)
Here's why the first one is a very bad idea:
$ var='my data is ab%scd'
$ printf "$var"
my data is abcd
Re: printf $variable inside initial parenthesis or use %s?,
David <=