Menu

#36 prevent accidential file overwrites by wildcard expansion

Default
pending
nobody
None
5
2025-04-29
2013-03-15
Jakub Wilk
No

A Debian user complained that if you use a wildcard as input file name, and the wildcard unexpectedly expands to two names, then rst2html will overwrite your files:
http://bugs.debian.org/654690

Would if be possible to add an option for not overwriting output files, that you could add to your configuration file, and later override from command line if needed?

Discussion

  • David Goodger

    David Goodger - 2013-03-15

    I'm inclined to answer "won't fix" or "not a bug" here.

    If we did add a --no-clobber option, I very much doubt anyone would use it before it's too late.

     
  • David Goodger

    David Goodger - 2013-03-15
    • status: open --> pending
    • milestone: -->
     
  • engelbert gruber

    no-clobber is ok, but

    1. Would if be possible to add an option for not overwriting output files,that you could add to your configuration file,
    2. and later override from command line if needed?

    is ...

     
  • David Goodger

    David Goodger - 2013-03-16

    Sure, --no-clobber & --clobber-ok/--go-ahead-and-clobber/--overwrite or something like that. But my opinion is YAGNI: you ain't gonna need it. Anybody who clobbers their input files using wildcards is not likely to know about or use such options. (PEBKAC)

    Even if we did implement such an option, I would not make it the default.

    We have better things to spend our time on. Unless somebody champions this issue, I vote to close/reject it.

     
  • Günter Milde

    Günter Milde - 2022-07-07

    Since 3.3, Python's standard open() supports the "mode" argument value
    'x' open for exclusive creation, failing if the file already exists
    which could help with the implementation of such an option.

     
  • Günter Milde

    Günter Milde - 2022-07-07

    The original problem (accidential overwriting because of shell expansion, http://bugs.debian.org/654690) would also be solved by a different syntax for the output file:
    instead of rst2html infile outfile we could use the signature

    rst2html infile [infile2 [infile3 [...]]] --output=outfile
    

    which would:

    • prevent interpretation of an "accidential" second argument as outfile (and hence overwriting),
    • be in line with usability recommendations,
    • allow chaining of rST source files, e.g. prepending a file that defines roles or substitutions or combining chapters/parts without requiring a master document.
     
    👍
    1
    • engelbert gruber

      I like the --output= solution

      of course this will break a ton of scripts
      therefor requires a deprecation warning
      and will take years

       
      • Günter Milde

        Günter Milde - 2022-07-13

        I like the --output= solution
        of course this will break a ton of scripts therefore requires
        a deprecation warning and will take years

        Indeed.

        We may start with deprecating the "-o" shortcut for "--output-encoding".
        (And, for symmetry "-i" for "--input-encoding".)

         
  • Günter Milde

    Günter Milde - 2022-12-02

    Proposal:

       - <toolname> [options] [<source> [<destination>]] 
       + <toolname> [options] source [source2 [source3 [...]]]
    

    Announce upcoming changes in Docutils 0.19

    • new option --output=destination in Docutils 0.19

    • removal of the short options -i and -o in Docutils 1.0

    • removal of the second argument <destination> in Docutils 2.0

    • accept more than one source document in Docutils 3.0

    • short option -o for --output in Docutils 3.0

     
  • Günter Milde

    Günter Milde - 2023-04-18
    • summary: option for disallowing file overwrites --> prevent accidential file overwrites by wildcard expansion
    • status: pending --> open-accepted
    • Group: --> Default
     
  • Günter Milde

    Günter Milde - 2023-04-18

    The upcoming change to the command line API is now announced in the RELEASE-NOTES.

     
  • Günter Milde

    Günter Milde - 2025-04-29
    • status: open-accepted --> pending
     
  • Günter Milde

    Günter Milde - 2025-04-29

    This is a work in progress due to backwards incompatible changes. It will be finished in Docutils2.0.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.