~cdrozak/cdro-wiki

f4ed1bd7696e21aba614be2a59b359c02042a93d — Cezary Drożak 3 months ago 6a0431e
tcl: add article
2 files changed, 36 insertions(+), 0 deletions(-)

M index.md
A tcl.md
M index.md => index.md +1 -0
@@ 32,6 32,7 @@ the Internet and don't want to get lost.
- [C and C++](c-and-cpp.md)
- [Lua](lua.md)
- [Python](python.md)
- [Tcl](tcl.md)
- [TeX](tex.md)

## Shell

A tcl.md => tcl.md +35 -0
@@ 0,0 1,35 @@
---
title: Tcl
---

# Links

- [Tcl Commands](https://www.tcl.tk/man/tcl8.6/TclCmd/contents.html)
- [Tcl Style Guide](https://core.tcl-lang.org/tips/doc/trunk/tip/352.md)

# Getting script directory

The script file name can be discovered using the `info script` command. If that
doesn't work, the `$argv0` variable can be used:

```tcl
set ScriptPath [info script]
if {[string length $ScriptPath] == 0} {
   set ScriptPath $argv0
}
```

This conditional is not necessary if we know how the script will be executed,
which is often the case.

The next thing to do is to normalize the script path, to get the absolute path:

```tcl
set ScriptPath [file normalize $ScriptPath]
```

Finally, get the script directory using the `file dirname` subcommand:

```tcl
set ScriptDir [file dirname $ScriptPath]
```