Business Shell (BUSH) Guide
Author: Ken Burtch

Home Page | Introduction | Tutorials | Reference | Packages | Hacking

Packages
4.1 Using Packages
4.2 text_io (Console I/O)
4.3 text_io (File I/O)
4.4 sound
4.5 source_info
4.6 System
4.7 numerics
4.8 strings
4.9 command_line
4.10 lock_files
4.11 cgi
4.12 calendar
4.13 units
4.14 arrays
4.15 files
4.16 db (Database)
4.17 stats
4.18 pen
4.19 mysql
4.20 os
4.21 directory_operations
| This part of the guide contains detailed descriptions of the BUSH built-in packages. ### 4.9 command_line Package The command_line package provides communication between a script and the calling program. This package sets the exit status and processes command line option switches. command_line contains following routines: GCC Ada equivalent: Ada.Command_Line n := command_line.argument_count
return the number of script arguments (the same as $#). Exclude BUSH option switches. Example: if command_line.argument_count > 0 then ... Ada Equivalent: Ada.Command_Line.Argument_Count Parameters:
n | return value | natural | required | the argument count
s := command_line.argument( p )
return a command line argument (the same as $n where n is a number). The arguments do not include option swithes interpreted by BUSH. Example: put_line( "First argument is " & command_line.argument( 1 ) ); Ada Equivalent: Ada.Command_Line.Argument Parameters:
p | in | positive | required | the argument number
s | return value | string | required | the value of the argument
A bad argument number will raise an exception. s := command_line.command_name
return the the name of the script or BUSH interpreter (the same as $0) Example: put_line( command_line.command_name & " is this script" ); Ada Equivalent: Ada.Command_Line.Command_Name Parameters:
s | return value | string | required | the name of the script or BUSH interpreter
n := command_line.environment.environment_count
return the number of variables in the operating system environment. Example: for i in 1..command_line.environment.environment_count loop ... Ada Equivalent: Ada.Command_Line.Environment.Environment_Count Parameters:
n | return value | natural | required | the argument count
s := command_line.environment.environment_value( p )
return an operating system environment value in the form of "VAR=value". Example: put_line( "First value is " & command_line.environment.environment_value( 1 ) ); Ada Equivalent: Ada.Command_Line.Environment.Environment_Value Parameters:
p | in | positive | required | the argument number
s | return value | string | required | the value of the argument
A bad environment value number will raise an exception. command_line.set_exit_status( n )
set the status code to be returned by the script to the calling program. (To read the exit status, use os.status.) Example: command_line.set_exit_status( 0 ); -- all is well Ada Equivalent: Ada.Command_Line.Set_Exit_Status Parameters:
i | in | short_short_integer | required | the status code to return (0 for no error)
End of Document Back to Top