Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14292
| Path | csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Ilkka Virta <itvirta@iki.fi> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Redirect to variable |
| Date | Tue, 3 Jul 2018 15:52:59 +0300 |
| Lines | 29 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.3001.1530622411.1292.bug-bash@gnu.org> (permalink) |
| References | <CALDPARB9JA75enT1bRa6wFQJsTwLPxibbB99jjvpMj9u2CwFtg@mail.gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | usenet.stanford.edu 1530622412 25879 208.118.235.17 (3 Jul 2018 12:53:32 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-bash@gnu.org, Chester Ramey <chet.ramey@case.edu> |
| To | Robert Durkacz <robert.durkacz@gmail.com> |
| Envelope-to | bug-bash@gnu.org |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
| In-Reply-To | <CALDPARB9JA75enT1bRa6wFQJsTwLPxibbB99jjvpMj9u2CwFtg@mail.gmail.com> |
| Content-Language | en-US |
| X-SASI-RCODE | 200 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; h=subject:to:references:cc:from:message-id:date:mime-version:in-reply-to:content-type:content-transfer-encoding; s=smtp; bh=+6XOiWeqNdjWFusmFOgui4NuGtslAARxSylsjznXzzk=; b=0+0QF/9GPKfyCQmdGT5AKA6WdMrbw81xo7toM2WGR6SpYuHIO1IHaJG10R3CTexq2ZzI1it4v70blWB82YX001wGWBr/50Mx1HfTJhecNe0PM0cAic8QaD/2qOTLeT82AaG69YD8IOtEz76HI8RcnBBVKXwQ4NViCjyQ81iEdYTQ5wn0Ie652mrYix1bAyOywcT8y/ftXJ0aZVgGL/j/hvAA2GVTGZ8cx+c+K5INX+Q0p5wLNvZixxCMpUVWtD98mNI4ZgqV0x+KRgukwkcjgAvPJ9Rj0L01bgm8Q1GCnABqpuwVIkx93bzYAyNwJVMYMcJtc1b8s2CDxNqWGWsC3A== |
| X-detected-operating-system | by eggs.gnu.org: FreeBSD 8.x [fuzzy] |
| X-Received-From | 157.24.2.104 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <http://lists.gnu.org/archive/html/bug-bash/> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| Xref | csiph.com gnu.bash.bug:14292 |
Show key headers only | View raw
On 3.7. 15:43, Robert Durkacz wrote:
> On 5/21/18 Chet Ramey wrote:
>> What you're asking for is syntactic sugar for:
>
>> some-command > temp-file
>> echo '#' >> temp-file
>> variablename=$(< temp-file)
>> rm -f temp-file
>> variablename=${variablename%?}
>
>> I would look at a sample implementation, possibly using mmap, if someone
> did one.
>
> Could someone please explain the reason for inserting and removing the #
> character. It is as if to ensure temp-file is non-empty but it seems to me
> it would work anyway.
Command substitution removes any trailing newlines. Adding an extra
character to the end prevents that, but then that character itself needs
to be removed. (Actually, the 'echo' adds a # and an NL, but then the
command substitution removes the NL so the # remains as last character.)
Run something like printf "foo bar\n\n" > temp-file and then try the
above with and without the #.
--
Ilkka Virta / itvirta@iki.fi
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Redirect to variable Ilkka Virta <itvirta@iki.fi> - 2018-07-03 15:52 +0300
csiph-web