setting the argv variable in scotty

Robert Premuz (rpremuz@srce.hr)
Sat, 1 Jun 1996 16:21:51 +0200 (MET DST)

Hello,

I'd like to complain about the way scotty interpretor (version 2.0.2)
sets the argv variable.

The scotty(1) man page says:
argv Contains a Tcl list whose elements are the
arg arguments, in order, or an empty
string if there are no arg arguments.

Unfortunately, I do not understand what the 'arg arguments' are, but
the C code in the scotty.c file has taught me that this is something
strange. My conclusion is that scotty investigates the arguments of
the script it is invoked from before passing them to the script in the
argv variable.

To feel the pain, run the following script with different arguments
and see what it prints out:

#!/usr/local/bin/scotty -f
# this is a.tcl
puts $argv
exit

For example, when you execute:

% a.tcl -an_option -n - -- -n x - --

scotty considers the first -n option as its own option. Also, it
swallows the first '-' and '--' option, while the unrecognised options
and the arguments after the first '--' are passed to the script. So,
if the '--' option is used as the first argument of a script, as in:

% a.tcl -- -n

then further arguments are not investigated and are passed to the
script in the argv variable.

To remind you, scotty currently recognises the following options:

-? # This is not documented - it prints the usage message.
-n
-i
-c command
-f file
-- # This is not documented - it prevents further arguments
# from being investigated.

One could consider such behaviour of scotty a little bit strange and
would prefer that all arguments after -c command or after -f file were
not investigated (which would make the '--' option unnecessary).

But, as such a change will probably make the current scripts which use
the '--' option work incorrectly, I suggest keeping the current
behaviour (you know the saying: nothing lives longer than an error).

In any case, the man page should be upgraded. My suggestion follows
(note the different order of the options which is more logical, I
guess):

SYNOPSIS
scotty [ -? ] [ -n ] [ -i ] [ -c command ] [ -f file ] [ -- ]

DESCRIPTION
scotty is a Tcl interpreter with extensions to obtain status
and configuration information about TCP/IP networks. After
startup, scotty evaluates the commands stored in
$HOME/.scottyrc.

OPTIONS
-? Print the usage message.

-n Don't read the file $HOME/.scottyrc.

-i Initialize the interpreter to run a script for the
tkined(1) editor. This option will set up the correct
search path.

-c command
Process command and exit. This is useful for writing
shell scripts.

-f filename
Evaluate the commands contained in filename.

-- Prevent further arguments from being investigated.
scotty investigates the arguments of the script it is
invoked from before passing them to the script in the
argv variable. In this investigation, it excludes every
'-' not followed by additional characters, and excludes
and applies the arguments recognised as the above
options. The investigation stops at the first argument
which does not begin with a '-', or at the '--' option.
In the later case, the '--' option is not passed in the
argv list.

% scotty -c 'puts $argv' Looking forward to your comments

v
-- rpr. : Robert B. Premuz
Internet: rpremuz@malik.srce.hr * Voice at home: +385 (0)1 687564