Re: How to escape $?...

On Sat, 25 Mar 2006 09:19:48 +0100
Hans Durast <65644434343@xxxxxxxxx> wrote:

> How to escape sequences like '$?', '?'  in command line?
> I have a construct like this:
> 
> |Xdialog --yesno "really delete???\n%%f" 7 0; sh -c "if [ $? == 0 ]; 
> then kdesu 'rm -rf %f'; fi"
> 
> It works on the last Version of emelfm2, but not on the newest.
> 1. There is no '???' in the Xdialog-message, tried '\?': nothing
> 2. I had to replace '\n' to '\\n' for a line break, this works
Someone proposed that escape chars be filtered from commands. I guess that 
needs more thought.

> 3. '$?' results in nothing
0.1.6 will treat the ? as a wildcard, and so try to expand $? into matching 
itemname(s), which in general would find nothing.
 
> What can I do?
apply the following, and rebuild

--- e2_utils.c-original 2006-03-25 22:54:02.000000000 -0500
+++ e2_utils.c  2006-03-25 22:59:00.000000000 -0500
@@ -1174,4 +1174,6 @@
                if (strchr (arg, '*') == NULL && strchr (arg, '?') == NULL)
                        return NULL;
+               if (g_str_has_prefix (arg, "$"))        //some shell or 
language variables can be ignored
+                       return NULL;
                path = curr_view->dir;
                name = arg;

While we're at it, are there any other special-cases that we should watch for ?

Regards
Tom


-- 
Users can unsubscribe from the list by sending email to 
emelfm2-request@xxxxxxxxxxxxx with 'unsubscribe' in the subject field or by 
logging into the web interface.

Other related posts: