[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 09:47:16 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Mon, Mar 30, 2015 at 02:02:10PM +0100, Stephane Chazelas wrote:
> It's really strange that no shell, not even zsh or fish fixed
> that (removing all trailing newlines instead of just only one).
>
> The usual work around is to do
>
> var=$(cmd && echo .) && var=${var%?} && var=${var%?}
> (to remove only one newline)
>
> but that's obviously a pain.
In #bash we (de facto) agreed on this version:
var=$(cmd; printf x) var=${var%x}
Which is basically the same as yours, and I agree it's somewhat odd
that nobody ever came up with a shopt to stop $() stripping newlines.
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, (continued)
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Eric Blake, 2015/03/25
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Eric Blake, 2015/03/25
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Chet Ramey, 2015/03/26
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Eric Blake, 2015/03/26
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Stephane Chazelas, 2015/03/29
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Greg Wooledge, 2015/03/30
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Stephane Chazelas, 2015/03/30
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?,
Greg Wooledge <=
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Stephane Chazelas, 2015/03/30
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Greg Wooledge, 2015/03/30
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Stephane Chazelas, 2015/03/30
- Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Stephane Chazelas, 2015/03/29
Re: [Help-bash] Transform strings with special characters so that the strings don't need to be quoted?, Stephane Chazelas, 2015/03/25