Closed joelpurra closed 9 years ago
This doesn't happen for me:
$ ../google-font-download "'Open Sans'"
Downloading 'Open Sans'... error: curl: (22) The requested URL returned error: 400 Bad Request
$ echo $?
1
I only need to quote once:
$ ../google-font-download "Open Sans"
Downloading Open Sans...eot woff svg ttf
$ echo $?
0
Consequently, this must somehow depend on your system. My guess would be your version of getopt. What does
getopt -T; echo $?
return on your system?
Assumed it had something to do with getopt
, but it was also clear it works for you =)
getopt -T; echo $?
--
0
Using Mac, so guess there's an incompatibility. I could brew install gnu-getopt
, but not keen on putting it in my $PATH
.
sw_vers
sw_vers
ProductName: Mac OS X
ProductVersion: 10.10.3
BuildVersion: 14D136
Yeah, that's what I expected. OS X ships with a version of getopt that doesn't get these things right. The manpage of GNU getopt is pretty clear on this:
Traditional implementations of getopt(1) are unable to cope with whitespace and other (shell-specific) special characters in arguments and non-option parameters. To solve this problem, this implementation can generate quoted output which must once again be interpreted by the shell (usually by using the eval command). This has the effect of preserving those characters, but you must call getopt in a way that is no longer compatible with other versions (the second or third format in the SYNOPSIS). To determine whether this enhanced ver sion of getopt(1) is installed, a special test option (-T) can be used.
The least I can do is add the check and warn that double quoting will be necessary for fonts with whitespace or other special characters.
@neverpanic: documentation and a warning is good enough for me, as it wasn't too hard to figure out a solution to the problem to start with either. Thanks!
@neverpanic: v1.2.1 looks good to me! The terminal output looks better too. Thanks! =)
I order to download a font with a space in the name, I had to quote the name with both double and single quotes.
This is in contrast with the docs which use
Open Sans
as an example, and only one set of quotes. Looking at the command output, it looks like the space will be parsed as two fonts,Open
andSans
.