Welcome to my Tcl/Tk page.

Bourne Again!

Bsh Package

Bourne Shell is UNIX's standard shell.
The Tcl package Bsh which includes two procedures
for processing lists like Bourne Shell in a Tcl script.

Specifications:

::bsh::IFS
	Internal  field   separators,   normally
	SPACE, TAB, and NEWLINE.

::bsh::set ?argument ...?
	The arguments are positional parameters  and  are
	assigned, in order, to $1, $2, and so on.  If
	no arguments are given,  the  values  of  all
	names are printed.

::bsh::shift ?n?
	The positional parameters are shifted to  the
	left, from position n+1 to position 1, and so
	on.  Previous values for $1  through  $n  are
	discarded.   If n is not given, it is assumed
	to be 1.

License:

The Bsh Package is free software.
This software is copyrighted by Satoshi Imai.

Download:

You can get the package here.

bsh10.zip

The Bsh package is 100% Pure Tcl.
Please note that you can install only for Tcl8.0 or higher.

Samples:

# Sample 1
package require bsh

::bsh::set {AA BB CC}
puts ${#}
=>3
puts "$1 $2 $3"
=> AA BB CC
puts ${*}
=> AA BB CC

::bsh::shift
puts ${#}
=>2
puts "$1 $2"
=> AA BB
puts ${*}
=> AA BB
# Sample 2
package require bsh

set ::bsh::IFS ":"
::bsh::set {AA:BB:CC}
puts ${#}
=>3
puts "$1 $2 $3"
=> AA BB CC
puts ${*}
=> AA BB CC

::bsh::shift
puts ${#}
=>2
puts "$1 $2"
=> AA BB
puts ${*}
=> AA BB
# Sample 3
package require bsh

proc foo {args} {
    ::bsh::set $args
}

::bsh::set $argv

See Also:

tclGetOpts


Satoshi Imai
[HOME]