aboutsummaryrefslogtreecommitdiff
path: root/tclcompat.tcl
AgeCommit message (Collapse)AuthorFilesLines
2020-12-26try: reimplement in CSteve Bennett1-66/+0
For speed and size, since it shares a lot of the same code with catch Signed-off-by: Steve Bennett <steveb@workware.net.au>
2017-11-08tclcompat.tcl: minor comment updatesSteve Bennett1-3/+4
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2017-10-17signal, exec, wait, pid: improvements, especially to execSteve Bennett1-3/+18
- fix popen [open "|pipeline ..."] to return meaningful status in close (but note that stderr is not captured) - popen pipelines can now be used as the target of exec redirection - overally improvements to exec on windows. Now crt file descriptors are used throughout - add support for [pid], [wait] and popen on windows - os.wait is now wait, and integrates with [exec ... &] to be able to wait for running background tasks - [socket pipe] is now also [pipe] and is supported on windows - [file tempfile] is supported on windows - move duplicated code between jim-aio.c and jim-exec.c to jimiocompat.c - Fix [exec] on windows to match unix semantics wrt sharing the parent stream unless redirected rather than using /dev/null - On windows redirect to or from /dev/null is automatically converted to NUL: - If signal support is disabled, implement a minimal Jim_SignalId() for exec and wait - aio now supports getfd, to return the underlying file descriptor. This is used by exec to support redirection, and allows popen channels to support exec redirection. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-09-29jimsh: Scriptable command-line completion supportSteve Bennett1-10/+4
via tcl::autocomplete Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-12-04try: fix use of catch/uplevelSteve Bennett1-3/+3
Use catch {uplevel 1 $script} instead of catch [list uplevel 1 $script] to ensure that source info is not lost. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-12-04file copy: Use binary mode when reading and writing filesSteve Bennett1-2/+2
Matters on Windows Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-21many comment changes, some small code changesSteve Bennett1-2/+4
Sweep through and clean up all (most) of the comments in the code. While there, adjust some variable and function names to be more consistent, and make a few small code changes - again, mostly for consistency. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15tclcompat: it is finally time to remove [case]Steve Bennett1-41/+0
Use [switch] instead Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15pid: error message is now tcl 8.6 compatibleSteve Bennett1-5/+5
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-11-07Improve file copy -force identical file checkSteve Bennett1-1/+6
On mingw we can't rely on dev+ino check Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-11-07file copy -force handles identical source/targetSteve Bennett1-3/+10
No longer truncates the file Reported-by: sg0x40 <https://github.com/sg0x40> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2012-02-10Sense of fconfigure ... -blocking is reversedSteve Bennett1-1/+1
We implement fconfigure -blocking via $sock ndelay, but the sense of ndelay is the reverse of -blocking Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-12-02Correct the documentation for 'local'Steve Bennett1-1/+1
Also some general documentation cleanups and trailing white space removal. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-09-12Implement full [exec] on mingw/msysSteve Bennett1-1/+1
This also involves some restructuring of the existing implementation to allow for as much reuse as possible. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-07-07Support and ignore fconfigure -translation ...Steve Bennett1-0/+3
Jim is always in binary/utf-8 mode This makes it easier to run Tcl scripts unmodified Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-07-07Add support for file delete -forceSteve Bennett1-0/+8
Will recursively remove directories, even if not empty. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-06-10Add aio support for bufferingSteve Bennett1-0/+16
And fconfigure for Tcl compatibility Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-06-01Add [upcall] commandSteve Bennett1-5/+2
Allows previous command definitions to be invoked when otherwise hidden via [local] Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-05-27closing an 'open |...' filehandle should waitSteve Bennett1-0/+6
for the detached child processes to complete. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-05-19Fix some missing closing bracketsSteve Bennett1-2/+2
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-12-06Make tclcompat work without aioSteve Bennett1-22/+23
This is an unusual case, but useful for testing Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-11-24Remove the bio extension and add 'copyto' to aio.Steve Bennett1-1/+1
The bio extension is a hangover from TinyTcl. Since Jim supports binary strings, there isn't much need for it except for 'bio copy'. So move this to aio as 'copyto' and implement 'file copy' in terms of it. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-11-08Don't hardcode /lib/jimSteve Bennett1-15/+0
Instead, set TCL_LIBRARY based on where jim is installed. This defaults to /usr/local (thus /usr/local/lib/jim), or can be modified with either configure or make. e.g. ./configure --prefix=/usr or make prefix=/usr install Now auto_path is initialised only to TCL_LIBRARY, and doesn't include "." which could be undesirable. At the same time, simplify jimsh initialisation using a script instead of C code. Add the path to the executable to auto_path. Also, no longer use JIM_TCL_COMPAT. Always use the tcl-compatible names, $auto_path and $tcl_interactive. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-30Determine platform_tcl() settings with configureSteve Bennett1-2/+0
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Portability fixesSteve Bennett1-0/+2
Especially for eCos, mingw32 and cygwin Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Remove dependence of jim core on stderrSteve Bennett1-22/+0
Remove Jim_PrintErrorMessage() and create Jim_MakeErrorMessage() instead. Move errorInfo to stdlib since it is now required. Also move lassign from tclcompat to stdlib as a core command. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Implement 'pid handle'Steve Bennett1-5/+27
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Implement Tcl I/O wrappers in TclSteve Bennett1-1/+31
This allows 'rename' etc. to work correctly and is smaller, simpler code Also, read -nonewline is mutually exclusive with 'numChars' Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Ensure that Tcl extensions can be built-in or externalSteve Bennett1-2/+0
All C extensions must call Jim_PackageProvide() make-c-ext ensures that Tcl extensions call Jim_PackageProvide() if compiled in. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Add do-nothing fileevent for Tcl compatibilitySteve Bennett1-0/+5
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Add an optional 'putter' function to parraySteve Bennett1-3/+5
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Implement open "|..."Steve Bennett1-0/+22
Uses a Tcl wrapper, popen, from tclcompat Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Implement 'info frame' and some related procsSteve Bennett1-16/+5
info frame allows access to source file/line for earler call frames Implement 'stacktrace' to give a live stacktrace And 'stackdump' to convert a stack trace to readable form Update 'errorInfo' to use 'stackdump' Also fix tailcall to retain source info And implement alias, lambda and curry with tailcall Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Improvements to tailcallSteve Bennett1-1/+1
Add tests and documentation Make tailcall work within 'try' Fix tailcall interaction with uplevel Use tailcall for dispatch in tree.tcl Also some related improvements in tree.tcl Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Move some core procs into the (Tcl) stdlib extensionSteve Bennett1-5/+4
Also implement 'local' to declare/delete local procs * Add tests/alias.test for testing alias, current, local * proc now returns the name of the proc created * Add helper 'function' to stdlib Reimplement glob and case to use local procs * This keeps these internal procs out of the global namespace Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Improvements to catch, return, signal, trySteve Bennett1-31/+89
Improve the ability to rethrow errors * Allow return to rethrow an error by accepting '-errorinfo stacktrace' * Also, 'catch ... opts' now also stores opts(-errorinfo) on error * Use these to provide better stack traces from 'case' and 'try' * Implement 'return -level' Make try/on/finally more Tcl 8.6 compatible * With support for 'on' handlers and docs Add support for catch options to try * Otherwise it's hard to use try to catch signals Improvements to signal handling * catch -signal now sets a list of the handled signals as the result * catch -signal won't execute the body at all if a handled signal is pending * up to 64 (jim_wide) signals can now be handled * if catch -signal is nested, the innermost catch will catch the error * new 'signal catch' allows ignored/blocked signals to be examined and cleared. * update docs on signal handling exec should indicate which signal killed the child Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Fix lassign to work properly with an empty listSteve Bennett1-2/+4
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Enhance catch and 'info returncodes'Steve Bennett1-1/+8
*: Add optional arg to catch, opts, like Tcl 8.5 to allow access to the code given by 'return -code' *: Use -- to signify end of options to catch *: 'info returncodes' can give the name of a single code *: Fix 'case' to handle 'return -code' properly
2010-10-15Add basic Tcl implementation of 'try ... finally'Steve Bennett1-15/+32
2010-10-15Improve stack trace handlingSteve Bennett1-13/+12
*: Get rid of JIM_ERR_ADDSTACK and use interp->addStackTrace instead *: 'return -code error' doesn't add a stack frame *: Rename _file_copy to {file copy} for better error messages *: Use 'return -code' to prevent excessive levels in the stack trace Also rename info_nameofexecutable to {info nameofexecutable}
2010-10-15Add support for 'file copy'Steve Bennett1-0/+23
2010-10-15Allow catch to specify what is caughtSteve Bennett1-7/+9
*: Default to the same as Tcl. Not signal, eval, exit. *: Use 'catch -exit' to also catch exit. *: Also map for standard return codes: [info returncodes] *: Also Jim_ReturnCode() *: Add Jim_FindByName() for searching in a char* array *: Fix 'info nameofexectutable' if $::jim_argv0 is not set
2010-10-15Bug fixes and featuresSteve Bennett1-0/+13
Support end+<n> index And generally simplify the index handling Add support for 'info nameofexecutable'
2010-10-15Various general fixes and cleanupsSteve Bennett1-0/+97
Add lsearch -command, update case to use lsearch Rename tcl6.tcl to tclcompat.tcl Remove // style comments Expand some tabs to spaces Fix some compiler warnings Remove some unused functions Don't close fd=-1 in exec