help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printf $variable inside initial parenthesis or use %s?


From: Roger
Subject: Re: printf $variable inside initial parenthesis or use %s?
Date: Thu, 12 Jan 2023 17:06:02 -0500

>> Think most of us know the more secure method, and the simple method provides 
>> easier reading.
>
>I disagree that it's "easier reading".  When I see
>
>    printf %s "$var"
>
>then I know exactly what it will do.  When I see
>
>    printf "$var"
>
>then I have to stop and verify that "var" is safe to (ab)use as a
>format string.

All prior information/suggestions are completely understandable.

>But it seems to me that you've made up your mind to use the sloppy
>method and are just looking to justify your decision, so go for it.
>
>
>-- 
>vq

Excuse me?

Another idea, initially write scripts using echo, then later re-code/fix and 
use printf.

This will save a lot of typing time, with echo/printf statements being added 
and removed during development (although I usually leave most echo/printf 
statements for later debugging), that do not remain in the final end product or 
working script.  Like I previously stated, printf %s syntax format tends to 
double typing time.  Albeit, using this tactic, most will just forget and keep 
the echo statements!

Roger

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]