DASH Shell discussions
 help / color / mirror / Atom feed
* local var=$(cat) only reads one line
@ 2012-04-08 22:09 Jim Pryor
  2012-04-09  1:12 ` Jim Pryor
  2012-04-09 15:34 ` Jilles Tjoelker
  0 siblings, 2 replies; 4+ messages in thread
From: Jim Pryor @ 2012-04-08 22:09 UTC (permalink / raw)
  To: dash

Hi, I'm not a subscriber to this list and am not sure where's the best
place to report this bug. A cursory search didn't find other reports of
the same issue; but I can imagine there may well be such. If so, excuse
the noise. I'm just trying to help.

I notice the following issue in the version of dash that's bundled in a
recent release of finnix (not sure which one, but the kernel version is
3.0.6, so it's probably finnix 103, released 23 October 2011). I also
see it in the FreeBSD sh, from a FreeBSD-9 release candidate I compiled
in January. I know that's not dash, but I understand the codebases are
closely related. Neither of these are my active systems; hence the fuzzy
details.

Here is a testcase:

#!/bin/dash

test1() {
    local IN=$(cat)
    printf "test1 <%s>\n" "$IN"
}

test2() {
    local IN="$(cat)"
    printf "test2 <%s>\n" "$IN"
}

test3() {
    IN=$(cat)
    printf "test3 <%s>\n" "$IN"
}

test4() {
    IN=$(cat)
    printf "test4 <%s>\n" "$IN"
}

MSG=$(printf "abc\ndef\nghi")

printf "%s" "$MSG" | test1
printf "%s" "$MSG" | test2
printf "%s" "$MSG" | test3
unset IN
printf "%s" "$MSG" | test4

#######

The weird bit only shows up in test1: IN will only be assigned the first
line of stdin.

Hope this helps someone.
-- 
dubiousjim@gmail.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-09 16:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-08 22:09 local var=$(cat) only reads one line Jim Pryor
2012-04-09  1:12 ` Jim Pryor
2012-04-09 16:23   ` Jim Pryor
2012-04-09 15:34 ` Jilles Tjoelker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox