You could use escape characters before each special character (<
, [
, >
, ]
), but that'd be quite cumbersome in this case. Instead, you can simply surround the entire argument with single quotes as follows:
$ ./a.out '<font name="Moronicity" size=12><!-- ignore this comment --><i></i>
<div style="aa">hello</div></font><img src="spacer.gif">
<div style="bb"><img src="spacer.gif"></div>'
Another option is to place the parameter string
<font name="Moronicity" size=12><!-- ignore this comment --><i></i>
<div style="aa">hello</div></font><img src="spacer.gif">
<div style="bb"><img src="spacer.gif"></div>
into a file (for example, params
). This allows calling of your function in combination with the cat
command, which outputs the contents of a file:
$ ./a.out "$(cat params)"
Note that the $()
is used to execute the cat params
command, and the double quotations are used to include the entirety of the file as the parameter to a.out
. With the combination of the two, we can pass the contents of the file into the parameters of your program.