Fork us on GitHub Follow us on Facebook Follow us on Twitter

Opened 3 years ago

Last modified 5 months ago

#653 new enhancement

Advanced shell scripting in Bdsh

Reported by: Vojtech Horky Owned by:
Priority: major Milestone:
Component: helenos/app/bdsh Version: mainline
Keywords: gsoc16, gsoc17 Cc:
Blocker for: Depends on:
See also:

Description

Implement support for control structures (loops and conditionals), variables and pipes in Bdsh (HelenOS native shell).

Details
The currently used shell in HelenOS is Bdsh. It is used to start new tasks and has basic support for redirection of standard input and output. But it does not offer any advanced features such as loops or variables. Also there is no support for pipes, i.e. redirection of output of one task to the input of another one.

The goal of this ticket is to implement a script language suitable for HelenOS shell. The shell should support at least the following functionality:
  • Variables: assign values into variables, variables would be expanded to their values when being used during task launch.
  • Conditionals: write constructs that would conditionally execute one of its branches depending on value of a variable or properties of a file (e.g. its existence).
  • Loops: specify that a certain block of commands shall be executed multiple times.
  • Pipes: output from one program would be piped to the input of another one (possibly chained multiple times).
The applicant shall sketch the syntax of the scripting language as part of the proposal or (preferably) discuss it on the mailing list prior application submission.
What Gains and Benefits will this bring?
More shell features would improve the overall usability of the HelenOS terminal (console). It would be also possible to script more complex scenarios to better test HelenOS automatically. An example of such test is the file-system test (see information under the testing matrix).

Better scripting support would also be beneficial for the self-hosting scenario where HelenOS is supposed to be fully buildable inside HelenOS. Decent shell-scripting support is also a must-have for Coastline-ported software.
Difficulty
medium
Required skills
A successful applicant will have good skills of programming in the C language and some scripting language (Bash or similar) and the ability to survive in a non-standard non-POSIX application environment. Knowledge of parser and lexer generators (e.g. Bison or Flex) would be beneficial.
Documentation
Possible mentors
HelenOS Core Team, Vojtech Horky

Change History (1)

comment:1 Changed 5 months ago by Jiri Svoboda

I prefer that we implement a new shell from scratch with cleaner code and design. Bdsh is a POSIXish shell that was originally meant to run both in HelenOS and Linux. This limited its design to a fairly traditional one.

There are several aspects to a shell:

  • it interfaces with the user
  • it interfaces with the binaries it is executing
  • it provides an automation language

The implementation should be modular (e.g. using libraries) allowing e.g. different user interfaces to the same backend (e.g. for smooth integration with a file manager).

The automation does not need to be super sophisticated. It should, however, be cleanly designed and intuitive (i.e. running a commands just by typing them literally).

For purpose of running UNIX-style script(fragments) from ported software (configure.sh, Makefiles) a separate POSIX-compatible shell should be introduced (and here interactive mode is not a requirement) and is out of scope of this ticket.

Note: See TracTickets for help on using tickets.