2

I have simple application that is used to decrypt some value. The app take the decrypted value as a command line parameter, but i am seeing that the value i am passing from the command line is getting truncated.

Here is a very simple snippet

#include <iostream>

int main(int argc, char* argv[])
{
  std::cout << argv[1] << std::endl;
   return 0;
}

But when i run this app like this

./a.out GFjB5jgaUBVuN5c4fvuHvA==$YzgEE2VvWCMDImzTM9RYNQ==

I expect that the value GFjB5jgaUBVuN5c4fvuHvA==$YzgEE2VvWCMDImzTM9RYNQ== should be completely read but its getting truncated to GFjB5jgaUBVuN5c4fvuHvA====

What is the mistake i am making?

user996808
  • 143
  • 1
  • 10

1 Answers1

4

$NAME is replaced by the shell with the value of the shell variable NAME. You don't a shell variable called $YzgEE2VvWCMDImzTM9RYNQ, so that part is replaced with an empty string.

To avoid treating the $ character as a variable indicator, put the argument in single quotes:

./a.out 'GFjB5jgaUBVuN5c4fvuHvA==$YzgEE2VvWCMDImzTM9RYNQ=='
interjay
  • 107,303
  • 21
  • 270
  • 254