From: Michael Shigorin <mike@osdn.org.ua>
To: sysadmins@lists.altlinux.org
Subject: [Sysadmins] bash | read
Date: Thu, 17 Jan 2008 21:43:44 +0200
Message-ID: <20080117194344.GN7275@osdn.org.ua> (raw)
Здравствуйте.
Хозяйке на заметку (спасибо raorn@ за снятие с ручника насчёт subshell):
$ zsh
$ echo test | read a; echo $a
test
$ bash
$ echo test | read a; echo $a
$ echo test | ( read a; echo $a )
test
$
При этом что-нить вроде такого работает, как ожидается:
| while read first second junk; do
# something with $first (first IFS-delimited word)
# ...and with $second too...
# the rest of the line goes to $junk
done
-- именно потому, что тут-то всё выполняется в одном сабшелле ;)
А, и ещё:
$ echo test:best | ( IFS=: read a b; echo $a/$b )
test/best
--
---- WBR, Michael Shigorin <mike@altlinux.ru>
------ Linux.Kiev http://www.linux.kiev.ua/
next reply other threads:[~2008-01-17 19:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-17 19:43 Michael Shigorin [this message]
2008-01-18 9:44 ` Michael Shigorin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080117194344.GN7275@osdn.org.ua \
--to=mike@osdn.org.ua \
--cc=shigorin@gmail.com \
--cc=sysadmins@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux sysadmins discussion
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/sysadmins/0 sysadmins/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 sysadmins sysadmins/ http://lore.altlinux.org/sysadmins \
sysadmins@lists.altlinux.org sysadmins@lists.altlinux.ru sysadmins@lists.altlinux.com
public-inbox-index sysadmins
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.sysadmins
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git