0

It is possible to avoid interpreting special "Unix/Linux reserved" symbols in the terminal? For example, say that I have the following small C code:

int main(int argc, char* argv[]) {
  if (argc >= 1) {
    printf("Argument: %s\n", argv[1]);
  }
}

Now, If I pass as argument the following line

  ./my_program 100$$

The result that will get printed is "10028592", even if I try with double quotes, e.g "100$$". The same applies to other special symbols, e.g "&", "!!", "(" ..

Is there any way to pass those symbols as arguments?

Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
pureofpure
  • 1,060
  • 2
  • 12
  • 31

1 Answers1

1

Based on your question, it looks like you are using the Bash shell, or a shell similar for it.

Quoting the Bash Reference Manual, particularly its chapter on quoting:

3.1.2.2 Single Quotes

Enclosing characters in single quotes (‘'’) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.

3.1.2.3 Double Quotes

Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. [...]

dfrib
  • 70,367
  • 12
  • 127
  • 192