Author: Stan Eisenstat
Subject: Re: [Cs323] exec command parameter special characters
Date: Wednesday, 02 Sep 2020, 17:52:06
> Message Posted By: Anonymous > > I am specifically looking at this example and was hoping you could clarify > one thing. > > ./fiend . -exec echo foo '>' bar \; > > When I do system("echo foo '>' bar"), I am returned on the command line > "foo > bar" as opposed to piping foo into a file called bar. ... The call system("echo foo '>' bar"); executes the bash command echo foo '>' bar" which outputs foo > bar to the terminal. But with the single quotes replaced by spaces, the call system("echo foo > bar"); executes the bash command echo foo > bar" which writes "foo\n" to the file bar. When bash executes the command % ./fiend . -exec echo foo '>' bar \; it passes the list of arguments ("./fiend", ".", "-exec", "echo", "foo", ">", "bar", ";") to fiend. Since fiend does not re-escape the > (e.g., by restoring the surrounding single quotes, the string passed to system() will be "echo foo > bar" and the effect will be to write "foo\n" to the file bar. ===== > ... Is this > behavior correct for the function we are creating? Or do I have to parse > through the exec parameters and recognize that '>' is actually the pipe > symbol? Do you have any suggestions on the easiest way of doing this? If the response above does not answer these questions, please ask again. --Stan-PREV INDEX NEXT