wget-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

wget2 | Similarity of --output-file/-o and --output-document/-O (#675)


From: Mark Collins (@Marcool04)
Subject: wget2 | Similarity of --output-file/-o and --output-document/-O (#675)
Date: Sat, 27 Jul 2024 09:29:23 +0000


Mark Collins created an issue: https://gitlab.com/gnuwget/wget2/-/issues/675



Hi all,

First of all, thanks for all the great work on wget2, it's a wonderful tool 
that I use daily.
What I would like to open a discussion on is the potential footgun that the 
similarity in the two options `--output-file/-o` and `--output-document/-O` 
represents. Consider the following example:

```
$ cd Downloads/
$ wget2 "https://www.example.com/large_archive.tar.gz";
[goes on for a while...]
[is interrupted by power outage or whatever]
```
Fortunately, this server, and wget2, support resuming HTTP transfers, so off we 
go again. This time I'm in another working directory, so I specify the file in 
order for the `--continue/-c` option to work as intended:

```
$ wget2 -o Downloads/large_archive.tar.gz -c 
"https://www.example.com/large_archive.tar.gz";
```
Wooooops! So now, I have just clobbered the first 20Gb (or whatever) which I 
had already downloaded with the log from wget2's output. Obviously, I meant:

```
$ wget2 -O Downloads/large_archive.tar.gz -c 
"https://www.example.com/large_archive.tar.gz";
```
Subtle difference, big result...

Obviously, I'm not asking that wget2 be so smart as to try and guess what I 
mean. It's a stupid mistake to substitute one CLI option with another, and the 
manual is clear enough. But I wonder if the proximity between those two options 
isn't something that could be avoided maybe. I just keep forgetting which is 
which, but it's also conceivable that people might make a typo between 
lower-case and upper-case "o". Also, conceptually, `--output-file` and 
`--output-document` aren't exactly very clearer in and of themselves as to what 
they do. I'm downloading a file right, so I'll go "--output-file=blabla". 
Woops. Wrong again.

So, ok, I make this mistake all the time, I want to stop clobbering stuff, I'll 
avail myself of the option `--clobber`! maybe put an `alias wget2='wget2 
--clobber=off'` somewhere:

```
$ echo "slkdjf" > test
$ wget2 -o ./test --clobber=off "www.example.com"
$ cat test 
[0] Downloading 'http://www.example.com' ...
Saving 'index.html'
HTTP response 200 OK [http://www.example.com]
```

Nope, the `--output-file/-o` option does not honor `--clobber=off`...

I'm not saying anything is broken here, but I feel that any one of several 
things might make the program more user-friendly:

1) One of the two options `--output-file/-o` and `--output-document/-O` could 
be renamed to something very different from the other, so there is no possible 
confusion. I would imagine this is the easiest to implement.

2) wget2 could (should?) honor `--clobber=off` for the `--output-file` option. 
Maybe a bit more involved.

3) wget2 could check if the file it is supposed to write its output too exists, 
and if so ask the user what to do (should I append? clobber? create a new 
file?) since there is clearly a use case for appending to an existing log file 
in scripts. This is obviously the most involved in terms of coding and might 
not even be considered necessary.

So there you have it. I would love to hear what others think of this, and if 
there's an easy way around it with wget2 as it stands that I have not thought 
of.

Thanks in advance,

Best regards,

Mark

-- 
Reply to this email directly or view it on GitLab: 
https://gitlab.com/gnuwget/wget2/-/issues/675
You're receiving this email because of your account on gitlab.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]