20

I right-clicked a POST request in Chrome and selected "Copy as cURL".

I got a curl command that includes the following:

--data-binary $'------WebKitFormBound

I am used to seeing curl requests that have a single flag and string. Like this:

$ curl -0 "output.txt"

I understand that the --data-binary command will POST binary data (presumably after converting the string, after the --data-binary switch, into binary). But what does the dollar sign mean?

What does the curl request mean if it has two dashes and a dollar sign?

2 Answers 2

23

The notation being used there $'...' is a special form of quoting a string recognised by a few shells like ksh (where it originated), zsh and bash.

excerpt

Strings that are scanned for ANSI C like escape sequences. The Syntax is $'string'

Example

$ echo $'hola\n'
hola

$

References

2
  • 1
    so basically the command says "scan the string for escape characters and print the formatted string then convert that printed string to binary"
    – bernie2436
    Commented Feb 17, 2014 at 20:55
  • @akh2103 - yes I believe that's how it works.
    – slm
    Commented Feb 17, 2014 at 20:56
1

Part of your question was answered. In answer to the other part, the "two dashes" is typically the long form use of a parameter.

It is common for commands to have both a long and a short form for any given parameter. For example, if you look at the manual for curl, you will see:

-a, --append
    (FTP  SFTP)  When  used  in  an  upload,  this makes curl...

The -a, --append means that you can use either -a or --append in order to use that parameter. The -a could be considered an abbreviation. Whether you use one or the other makes no difference, it is personal preference.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .