Author: Emiliano Gavilán <[email protected]> Author: aspect <[email protected]> State: Draft Type: Project Vote: Pending Created: 13-Jan-2021 Post-History: Keywords: Tcl, file Tcl-Version: 8.7 Tcl-Ticket: 560c5e438c47f5fdd34846dbb333ab96cb905416
This TIP proposes extending the
file stat and
file lstat commands to return
a dictionary if no
varName argument is provided.
The result of
file stat is traditionally stored in an array named by its
second argument. Now that dicts are available, a more ergonomic alternative is
to simply return a value that the caller can process with the
pass to other procs or return as a result. The original usage is preserved by
varName argument optional.
file stat and
file lstat commands are both changed in exactly the same
file stat as an example, its signature is changed from:
file stat name varName
file stat name ?varName?
With two arguments, it behaves exactly like before. With only one argument:
- errors are reported exactly as they would be if
- if no error occurs, the result is returned as a dict instead of by populating an array
file stat with only one argument would raise a
Old (and preserved) usage:
% file stat / st % parray st st(atime) = 1610459586 st(blksize) = 4096 st(blocks) = 8 st(ctime) = 1605692955 st(dev) = 64769 st(gid) = 0 st(ino) = 2 st(mode) = 16749 st(mtime) = 1605692955 st(nlink) = 18 st(size) = 4096 st(type) = directory st(uid) = 0
% file stat / type directory size 4096 mtime 1605692955 ino 2 dev 64769 atime 1610459586 uid 0 ctime 1605692955 nlink 18 gid 0 blksize 4096 mode 16749 blocks 8
The ticket modernize "file stat" interface includes a patch by Emiliano Galivan. This patch includes an update to the manual, a new test
cmdAH-28.14 and changes two existing tests to accomodate the new interface (
This document is placed in public domain.