help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Transform strings with special characters so that the st


From: Greg Wooledge
Subject: Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?
Date: Mon, 30 Mar 2015 07:55:45 -0400
User-agent: Mutt/1.4.2.3i

On Sun, Mar 29, 2015 at 10:41:53AM +0100, Stephane Chazelas wrote:
> ksh93 doesn't need a -v because it doesn't fork+pipe in
> var=$(printf %s "$var") (and that output will never end in a
> newline character).

The fact that you lose the newline is, in my opinion, a pretty strong
endorsement for having printf -v var.

arc3:~$ ksh
h:w$ foo='newline
> '
h:w$ bar=$(printf %s "$foo")
h:w$ echo "<$bar>"
<newline>

With Bash-style printf -v bar %s "$foo" the content would have been
copied properly.



reply via email to

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