Re: Solaris sed

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

 



On Thu, Jun 12, 2025 at 9:44 AM Paul Smith <paul@xxxxxxxxxxxxxxxxx> wrote:
> On Thu, 2025-06-12 at 01:50 -0400, Eric Sunshine wrote:
> > Had it used the simpler:
> >
> >     echo "$foo"
> >
> > this sort of problem (forgetting the "\n") would never have occurred.
>
> Just be aware that echo is not well-standardized: many versions of echo
> accept extra options or treat certain chars specially.  So, printf
> (which IS well-standardized) is always safer unless you are 100% sure
> that the text on the echo command line is simple: cannot start with a
> "-", doesn't contain special chars like backslash, etc.
>
> For portability I (personally) always prefer printf unless I know
> exactly what the text contains (like showing a static string).

Yup, you're right. I always do the same when I can't trust the
argument to be `echo`-safe, but apparently I wasn't thinking of that
case when I wrote the email. Thanks for the dose of sanity.





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux