Tiny Core Linux

Tiny Core Base => TCB Talk => Topic started by: ost on September 28, 2011, 04:25:08 AM

Title: Shell read options
Post by: ost on September 28, 2011, 04:25:08 AM
The shell command "read" does not have a --help or -h option to explain its supported options.
Can anyone point me to a doc?
(I use microcore_4.0)

Im trying to do "read line1 line2", and need a flag to tell it to grab full lines.
Title: Re: Shell read options
Post by: ost on September 28, 2011, 06:35:02 AM
Im going to reply myself here..
It looks like read does a line grab and shares it on the list of arguments based on some separators (space is one of them)
To pipe two lines to two variables I have to do ..|(read line1;read line2)

But a complete doc would still be nice.
Title: Re: Shell read options
Post by: SvOlli on September 28, 2011, 07:49:07 AM
You don't find documentation of "read", because it's a shell builtin. Try
Code: [Select]
type read
A possible option for a start is the bash manual. The ash used features a large subset of bash. So not everything you'll find there will fit (mostly not all options are implemented), but it's a fair start for understanding the builtin shell commands.
Title: Re: Shell read options
Post by: Rich on September 28, 2011, 08:21:31 AM
Hi ost
Here's a pretty good link on bash commands
http://ss64.com/bash/ (http://ss64.com/bash/)
Title: Re: Shell read options
Post by: maro on September 28, 2011, 10:25:07 PM
In general I tend to use this page (http://linux.die.net/man/1/ash) to as a man-page for 'ash'. But if it comes to some finer details like what options are supported by a particular builtin function of a BusyBox applet I found reading the source code to be the best approach. Of course I would then have to validate any "findings" trough some testing.

My hunch is that the 'readcmd()' function of the 'shell/ash.c' file is responsible for parsing of the 'read' options. Therefore I'd assume that the '-n nchars', '-p prompt', '-t timeout', '-u fd', '-r', and '-s' are supported.
Title: Re: Shell read options
Post by: ost on September 29, 2011, 03:48:00 AM
Thanks to all of you. I learnt something from this :)