WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Shell read options  (Read 2141 times)

Offline ost

  • Newbie
  • *
  • Posts: 41
Shell read options
« on: September 28, 2011, 01: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.

Offline ost

  • Newbie
  • *
  • Posts: 41
Re: Shell read options
« Reply #1 on: September 28, 2011, 03: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.

Offline SvOlli

  • Full Member
  • ***
  • Posts: 193
  • Linux Developer
Re: Shell read options
« Reply #2 on: September 28, 2011, 04: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.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11290
Re: Shell read options
« Reply #3 on: September 28, 2011, 05:21:31 AM »
Hi ost
Here's a pretty good link on bash commands
http://ss64.com/bash/

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Shell read options
« Reply #4 on: September 28, 2011, 07:25:07 PM »
In general I tend to use this page 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.

Offline ost

  • Newbie
  • *
  • Posts: 41
Re: Shell read options
« Reply #5 on: September 29, 2011, 12:48:00 AM »
Thanks to all of you. I learnt something from this :)