Skip to content

WriteFile bug #81

@badrelmers

Description

@badrelmers

the doc says that WriteFile() is equivalent to > .
but when I use WriteFile() with a file which contains content already, it will not truncate the file but will append it to the begining! overwriting only the bytes I write.
cat file.txt
result: ttttttttttt

script.Echo("zzz").WriteFile("file.txt")
result: zzztttttttt

I think we have to use O_TRUNC here

script/sinks.go

Line 112 in 32cf7a7

return p.writeOrAppendFile(fileName, os.O_RDWR|os.O_CREATE)

tested in windows 7 with golang v1.16.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions