From: Herbert Xu <herbert@gondor.apana.org.au>
To: Gioele Barabucci <gioele@svario.it>
Cc: dash@vger.kernel.org
Subject: Re: Dash only reads the first character from pipe (bash reads whole line)
Date: Sat, 14 Nov 2015 18:51:22 +0800 [thread overview]
Message-ID: <20151114105122.GA17789@gondor.apana.org.au> (raw)
In-Reply-To: <n25ren$pf5$1@ger.gmane.org>
Gioele Barabucci <gioele@svario.it> wrote:
>
> > The 'read' command seems to only read the first character and not the
> > whole line.
> >
> > Example / comparison with bash:
> >
> > # /bin/dash
> > # sudo modprobe nf_conntrack
> > # read MAX </proc/sys/net/netfilter/nf_conntrack_max
> > # echo $MAX
> > 2
> >
> > # /bin/bash
> > # read MAX </proc/sys/net/netfilter/nf_conntrack_max
> > # echo $MAX
> > 262144
>
> It this a known problem? Are there workarounds?
Yes it's a known problem, but arguably it's more of a kernel bug
than a dash bug (proc files cannot be read byte-by-byte). You
can work around it using cat
MAX=$(cat /proc/.../file)
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
prev parent reply other threads:[~2015-11-14 10:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-13 23:24 Dash only reads the first character from pipe (bash reads whole line) Gioele Barabucci
2015-11-14 10:51 ` Herbert Xu [this message]
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=20151114105122.GA17789@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=dash@vger.kernel.org \
--cc=gioele@svario.it \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).