Replies: 1 comment 2 replies
-
I did some further testing. It looks like the double backslash rule for double quotes is just false. I have caused some of my confusion myself, but some parts are still unclear. It is important to keep in mind that there are two layers of unescaping:
Some of my confusion was caused by forgetting the shell. But I believe that the only place the escaping behavior is documented is just false. I have figured things out by trial and error. The i3 IPC documentation doesn't document escaping rules. I assume that escaping rules in the userguide should be followed, but maybe they are true in the i3 config file only. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey. I'm trying to comprehend i3's escaping rules for the
exec
command of i3 IPC. I am integrating i3 IPC into a program I maintain and I need to implement perfect forwarding of the command line.This is how I understand the unquoting process when
exec
's argument is withing""
quotes (like this:i3-msg 'exec "true"'
):\\"
with"
as noted in documentation"
sh -c <CMDLINE>
as a single argument (I haven't verified whethersh
itself is executed or whether some other shell is run, but that shouldn't matter much)I have found no mention of escaping
\
itself. This means that either the documentation is lacking or that it isn't implemented. If it isn't implemented, it could be considered a flaw in the escaping system.Let's say that I want to make
i3
run the following program:i.e. run program with argv0
prog
(or\x70\x72\x6F\x67
in hex to be precise) and with argv1\\
(or\x5C\x5C
in hex).Because
i3
will pass it through a shell, the backslashes have to be doubled. I would expect the following command:to provide the following input to
prog
's argv1:it provides
instead. The following command:
indeed does provide
prog
with\\
as argv0. Note thatalso works, which is even weirder. I don't know why it works. When considering the exec quoting section of the user manual, which is to my knowledge the only place escaping is documented at all, the previous outputs do not make sense.
When I simulate the shell unescaping the arguments using
echo
:prog
receiveswhich is double the backslashes the program receives when run via
i3-msg
.I have examined
i3-msg
with strace to inspect the writes to the unix sockets. I have also manually interacted with it to make sense of this.I have many more questions about the escaping rules of i3 IPC, but this comment is already long and I believe that I will be able to answer the rest of my questions if I figure out the basics I am asking about in this discussion.
Beta Was this translation helpful? Give feedback.
All reactions