#615 Append mode "a" does not agree with APPEND mode

obsolete: 8.0p2
closed-fixed
nobody
2
2000-10-26
2000-10-26
Anonymous
No

OriginalBugID: 681 Bug
Version: 8.0p2
SubmitDate: '1998-09-23'
LastModified: '1999-11-05'
Severity: MED
Status: Released
Submitter: welch
ChangedBy: hobbs
OS: All
OSVersion: NA
Machine: NA
FixedDate: '1999-11-05'
FixedInVersion: 8.3b1
ClosedDate: '2000-10-25'

According to open(3tcl):
a Open the file for writing only. The file
must already exist, and the file is posi=AD
tioned so that new data is appended to the
file.

The semantics of this are unclear from this documentation, but I
contend that they should be the same as those of ANSI C "a", which are
to position the file pointer at the end of the file prior to each
write.

Otherwise, programs which want this (correct) behaviour will all have
to use the POSIX-derived {... APPEND ...} syntax.

(This bug/misfeature also exists in my private debianisation of
upstream 8.1a2.)

Ian.

-anarres:~/junk> cat t.tcl
foreach {fn mode} {t a u {WRONLY APPEND CREAT}} {
puts "testing $fn with mode $mode"
file delete -force $fn
set f1 [open $fn $mode]
set f2 [open $fn $mode]
fconfigure $f1 -buffering none
fconfigure $f2 -buffering none
puts $f2 "data f2"
puts $f1 "DATA WRITTEN WITH F1"
puts $f2 "more f2"
close $f1
close $f2
}
-anarres:~/junk> rm -f t.strace; strace -ot.strace tclsh8.0 t.tcl
testing t with mode a
testing u with mode WRONLY APPEND CREAT
-anarres:~/junk> cat t
DATA WRImore f2
H F1
-anarres:~/junk> cat u
data f2
DATA WRITTEN WITH F1
more f2
-anarres:~/junk> dpkg -S `type -p tclsh8.0`
tcl8.0: /usr/bin/tclsh8.0
-anarres:~/junk> dpkg -s tcl8.0
Package: tcl8.0
Status: install ok installed
Priority: optional
Section: libs
Installed-Size: 641
Maintainer: David Engel <david@debian.org>
Version: 8.0p2-3
Provides: tclsh
Depends: libc6, libreadlineg2 (>=3D 2.1-4), ncurses3.4, tcl8.0
Conflicts: tcl, tcl74 (<=3D 7.4p3-2)
Description: The Tool Command Language (TCL) v8.0 - Run-Time Package.
TCL is a powerful, easy to use, interpreted scripting language.

The only problem here is the bug in the docs for "a", in that
we should (and do) follow POSIX fopen, where "a" doesn't care
whether the file exists or not. However, there is a standard
difference between "a" and "APPEND", in that APPEND moves to
the end of the file on EACH write, while "a" only sets the
INITIAL postion to the end.
-- 11/05/1999 hobbs

Discussion

  • Brent B. Welch
    Brent B. Welch
    2000-10-26

    • priority: 5 --> 2
    • status: open --> closed-fixed