bugGNU Wget - Bugs: bug #49971, Tildes inside quotations in option...

 
 

bug #49971: Tildes inside quotations in option arguments aren't parsed correctly

Submitter:  Daniil Zhilin <generalfailer>
Submitted:  Sun 01 Jan 2017 05:09:37 PM UTC
   
 
Category:  Program Logic Severity:  3 - Normal
Priority:  5 - Normal Status:  Wont Fix
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  1.18 Operating System:  GNU/Linux
Reproducibility:  Every Time Fixed Release:  None
Planned Release:  None Regression:  None
Work Required:  None Patch Included:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 01 Jan 2017 10:11:27 PM UTC, comment #3: 

In regard to tilde, you can use some tricky constructions to exploit the fact that you don't have to quote all of the characters in an argument of a command line.  (In fact, the shell records whether each character was quoted, and the special treatment of tildes in Bash is triggered when "a word begins with an unquoted tilde character".)

Thus,

    wget -O ~/"image 17.jpg"

writes output into a file in your home directory whose name contains a space.

In regard to combining -O and -P, the manual page says:

       -O file
       --output-document=file
           The documents will not be written to the appropriate files, but all
           will be concatenated together and written to file.  If - is used as
           file, documents will be printed to standard output, disabling link
           conversion.  (Use ./- to print to a file literally named -.)

           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.

Since -P sets the root of the retrieval tree, and -O dispenses with a "retrieval tree" entirely, you would expect -O to override -P.  However, this should probably be documented more clearly.

Dale Worley <worley>
Sun 01 Jan 2017 08:35:12 PM UTC, comment #2: 

Oh right, that was dumb of me. Though weird that e.g. nano allows this quirk.

Daniil Zhilin <generalfailer>
Sun 01 Jan 2017 08:05:05 PM UTC, comment #1: 

The ~ expansion a a (POSIX) shell feature, not a wget feature.
If you use such a shell and want it to expand ~ into your home directory, do not quote.

Same with other tools:

$ touch ~/image.jpg
$ rm rm "~/image.jpg"
rm: cannot remove '~/image.jpg': No such file or directory

Tim Ruehsen <rockdaboot>
Group administrator
Sun 01 Jan 2017 05:09:37 PM UTC, original submission:  

This is valid at least for '-O' and '-P' options.

wget -O "~/image.jpg" https://upload.wikimedia.org/wikipedia/commons/f/fb/Blue_Wildebeest,_Ngorongoro.jpg
~/image.jpg: No such file or directory

On a related note, '-P' option gets ignored for me when both '-O' and '-P' are used.

OS: Arch Linux

Daniil Zhilin <generalfailer>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by worley (Posted a comment)
  • -email is unavailable- added by rockdaboot (Posted a comment)
  • -email is unavailable- added by generalfailer (Submitted the item)
  •  

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-01-01 rockdaboot StatusNone Wont Fix
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code