Re: Dash only reads the first character from pipe (bash reads whole line)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gioele Barabucci <gioele@xxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux