-1

Hello people i have a question about how the 'curl' parser works in a linux commandline:

i work on a jokto-linux-system where i write commandline instructions:

I want to know what is the difference of with checkmarks '...' and without those.

commandline with checkmarks:

curl 'http://localhost:80/uri/?$sortby=name' > data.json

commandline without checkmarks:

curl -i http://localhost:80/uri/?$sortby=name > data.json

The command with the checkmarks bring me back a http 200OK and a sorted response in json format. the other command without checkmarks brings me too 200OK but the response is unsorted. I dont know the reason why.

Thanks for the feedback

Paul
  • 1
  • 3

3 Answers3

0

First of all, those are called single quotes, not checkmarks. This is a checkmark: ✓

Bash understands single quotes as protecting text of an argument against interpretation. Typically, nothing that is single-quoted will have a special meaning, and will be interpreted just as plain text.

Without them, ? and $ have special meaning to bash: ? participates in "globbing" (expanding filenames to match patterns, where ? is a placeholder for a single character), and $ participates in variable expansion ($sortby will get replaced by the value of the variable sortby).

? might not match anything and so will be left alone, but $sortby, as the variable is likely is not defined, will get replaced by empty string. The end result is that before curl sees the argument, it will be transformed if unquoted, most likely becoming http://localhost:80/uri/?=name - not what you want.

There are some more characters that would mess up your command line even more if they were present; for example, !, &, parentheses and more. It is a good idea always to quote your URI.

Amadan
  • 191,408
  • 23
  • 240
  • 301
0

A checkmark () has no special meaning in shell.

A string quoted with single quote marks (') with stop characters with special meaning having that meaning (e.g. & won't put the script in the background and $ won't start a variable).

Further reading:

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

Thanks for the correct answer. Sorry for that but my googletranslator tranlate me from german="Häckchen" to english="checkmarks" and not to quotes. But normaly i know this word.

Paul
  • 1
  • 3