Questions tagged [quoting]

The use of quotation marks (typically, `'` or `"`) to mark tokens as string literals or strings subject to interpolation, or to treat multiple whitespace-separated tokens as a single unit.

Use this tag for questions about the correct use of quotation marks in programming, with respect to:

  • how to use quotation marks to mark text as a literal not to be interpreted in any way.
  • how to use quotation marks to mark text as subject to string interpolation.
  • how to escape (encode) quotation marks inside text already enclosed in quotation marks.

Especially in shell programming, with respect to:

  • when what quotation marks are needed, and if quoting is needed at all, including quoting of individual characters with \.
  • how to use quoting to partition a list of tokens into distinct arguments that may have embedded whitespace.
  • when quotation marks are considered part of the input vs. recognized syntactically by the shell (quote removal).
589 questions
31
votes
4 answers

Why do I get "/bin/sh: Argument list too long" when passing quoted arguments?

How long can be a command line that can be passed to sh -c ''? (in bash and in bourne shell) The limit is much lower than that from the OS (in case of modern Linux). For example: $ /bin/true $(seq 1 100000) $ /bin/sh -c "/bin/true $(seq 1…
Igor Chubin
  • 61,765
  • 13
  • 122
  • 144
29
votes
2 answers

How do I pass on script arguments that contain quotes/spaces?

I'm trying to write a script notify-finish that can be prepended to any command. When done, it will run the command given by the arguments following, then email the user when the command is complete. Here's what I have: PROG=$1 # Run command given…
axon
  • 688
  • 1
  • 7
  • 18
26
votes
5 answers

Remove surrounded quotes in vscode or toggle between quote and no quote

Is there any shortcut or extension for vscode which can help to remove surrounded quotes (single ' or double " ) around a selected text? See example below 'hello' ==> hello In other words, is it possible to have a feature which will toggle current…
rahoolm
  • 733
  • 2
  • 12
  • 22
24
votes
7 answers

Stripping single and double quotes in a string using bash / standard Linux commands only

I'm looking for something that will translate a string as follows, using only bash / standard Linux commands: Single-quotes surrounding a string should be removed Double-quotes surrounding a string should be removed Unquoted strings should remain…
Jason
24
votes
3 answers

bash variable expansion ${var:+"..."} in here-document removing double quotes?

I'm trying to understand why Bash removes double quotes (but not single quotes) when doing variable expansion with ${parameter:+word} (Use Alternate Value), in a here-document, for example: % var=1 % cat < ${var:+"Hi there"} > ${var:+'Bye'} >…
Andreas Luik
  • 241
  • 1
  • 4
24
votes
5 answers

Invoicing vs Quoting or Estimating

If invoices can be voided, should they be used as quotations? I have an Invoices tables that is created from inventory associated with a Job or Order. I could have a Quotes table as a halfway-house between inventory and invoices, but it feels like I…
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
24
votes
7 answers

quoting constants in php: "this is a MY_CONSTANT"

I want to use a constant in PHP, but I also want to put it inside double quotes like a variable. Is this at all possible? define("TESTER", "World!"); echo "Hello, TESTER"; obviously outputs "Hello, TESTER", but what I really want is something…
helloandre
  • 10,541
  • 8
  • 47
  • 64
22
votes
3 answers

Raising error in postgreSQL

CREATE OR REPLACE FUNCTION msgfailerror() RETURNS trigger AS ' BEGIN IF NEW.noces< new.first_column THEN RAISE EXCEPTION 'cannot have a negative salary'; END IF; return new; END' LANGUAGE plpgsql Trigger create trigger…
user1686308
  • 305
  • 2
  • 3
  • 5
20
votes
4 answers

General string quoting for TCL

I'm writing a utility (which happens to be in python) which is generating output in the form of a TCL script. Given some arbitrary string variable (not unicode) in the python, I want to produce a TCL line like set s something ... which will set TCL…
greggo
  • 3,009
  • 2
  • 23
  • 22
19
votes
5 answers

Quoting vs not quoting the variable on the RHS of a variable assignment

In shell scripting, what is the difference between these two when assigning one variable to another: a=$b and a="$b" and when should I use one over the other?
John
  • 301
  • 2
  • 5
18
votes
7 answers

Bash problem with eval, variables and quotes

I've been reading about quotes in bash here and everywhere else, but i got no help solving this problem. The thing is, I have a little script for doing backups in a loop. If I don't use eval then I have problems with $OPTIONS variable in rsync. But…
Cesar
  • 4,076
  • 8
  • 44
  • 68
18
votes
1 answer

clojure require syntax rationale

I'm having a hard time understanding (and therefore remembering) the clojure require syntax described here: http://clojuredocs.org/clojure_core/1.3.0/clojure.core/require. It seems both counter intuitive and non-uniform. For example, in the…
Kevin
  • 24,871
  • 19
  • 102
  • 158
17
votes
4 answers

f-string: unmatched '(' in line with function call

I'm trying to use f-strings in python to substitute some variables into a string that I'm printing, and I'm getting a syntax error. Here's my code: print(f"{index+1}. {value[-1].replace("[Gmail]/", '')}") I only started having the problem after I…
Cameron Delong
  • 454
  • 1
  • 6
  • 12
17
votes
2 answers

Bash: How to use operator parameter expansion ${parameter@operator}?

I've googled and tried so many things and never could get anything to work with ${parameter@operator}. All I find is more links to the same documentation. So I think a proper answer with practical examples would be very helpful to its…
Fireplume
  • 269
  • 2
  • 7
17
votes
5 answers

Powershell: passing json string to curl

I'm trying to pass a JSON string from within a powershell script to the build.phonegap.com api, using curl. According to phonegap's forum, when running on a Windows machine, the JSON data has to be formatted as: curl.exe -ku user@email:mypass -X PUT…
KoenJ
  • 1,093
  • 2
  • 13
  • 24
1
2
3
39 40