Re: [TCL] Help debugging behavior in new source command





Andrew Falanga wrote:
Don Porter wrote:
In article <443e700e$1@xxxxxxxxxxxxxxxxxxx>, Andrew Falanga wrote:
I'm working on a new source command that will manage a list of loaded
libraries for me. The code for the new source command is:
Let us count the opportunities for improvement...

I never claimed to be the best :-)

rename source _source

proc source { pathToFile } {
global libraryIndex
if { ![file exists $pathToFile] } {
Log "File: $pathToFile does not exist"
exit
}
Process exit is a pretty severe reaction to a missing file.
Sure that's what you want?

In this case, I'm pretty sure that is what I want. I'm typically going
to be sourcing in libraries and if I can't find them, the script won't
run anyway.

except you are replacing a commonly used command that may be used
by other bits of code you don't control, so you should match the
behavior of the original command - which is to throw an error -
not exit. Perhaps you will use a library that has multiple
implementations and is coded to handle it by trying to source
a file, and if that fails alls back to another one, suddenly
it now exits instead. the proper place to add the exit is in
your application code that *calls* source - there is where the determination if the error is fatal or not is appropriate.

Bruce
.



Relevant Pages

  • Re: When will exit(0) fail to exit?
    ... If no arguement is given, ... If no arguement is given on command line, ... The exit(0) can not exit. ... The other libraries may hook into platform-specific initialization ...
    (comp.lang.c)
  • Re: When will exit(0) fail to exit?
    ... If no arguement is given, ... It also links with other libraries. ... If no arguement is given on command line, ... The exit(0) can not exit. ...
    (comp.lang.c)
  • Re: dd command & reading in background
    ... ^ D,"UnixReview: Shell Corner: The dspl Korn Shell ... user input timeout, do a search on C.U.S. for the ... # 0<c<127 - job exited with this exit code ...
    (comp.unix.shell)
  • Re: Ideas for Date and Time functions
    ... With regard to introduction to mumps commands, ... a better way to "discover" utilities, code patterns and libraries, ...     a. ...
    (comp.lang.mumps)
  • Re: How do you make this Open Source work on Solaris ?
    ... After running the tar -xvf command, I logged in /bin/csh and did the ... checking for gcc... ... checking for C compiler default output... ... checking how to recognise dependent libraries... ...
    (comp.unix.programmer)