Bug 682912 - wget -O truncates the output file before attempting the download.
Summary: wget -O truncates the output file before attempting the download.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: wget
Version: 5.6
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: Karsten Hopp
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-03-07 23:21 UTC by Guil Barros
Modified: 2018-11-14 14:09 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-03-08 12:44:12 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Guil Barros 2011-03-07 23:21:12 UTC
Description of problem:
# wget -O /etc/resolv.conf "http://people.redhat.com/gbarros/blah"
will truncate the output file before doing the dns lookup, thus failing and trashing the file.

open("/etc/resolv.conf", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3


Version-Release number of selected component (if applicable):
wget-1.11.4-2.el5_4.1.x86_64

How reproducible:
every time

Steps to Reproduce:
1. wget -O /etc/resolv.conf "http://people.redhat.com/gbarros/blah"
  
Actual results:
-O file gets clobbered

Expected results:
File is downloaded to a temporary location and moved into place when the download is complete.

Comment 1 Karsten Hopp 2011-03-08 12:44:12 UTC
That's expected and documented behaviour, this is from the man page:

Use of -O is not intended to mean simply "use the name file instead of the one in the URL;" rather, it is analogous to shell redirection: wget -O file http://foo is intended to work like wget -O - http://foo > file; file will be truncated immediately, and all downloaded content will be written there.


Note You need to log in before you can comment on or make changes to this bug.