bugGNU Parallel - build and execute command lines from standard input in parallel - Bugs: bug #35268, shell_quote doesn't treats []...

 
 

bug #35268: shell_quote doesn't treats [] brackets correctly

Submitted by:  Tim Cuthbertson <gfxmonk>
Submitted on:  Mon 09 Jan 2012 10:36:13 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 10 Jan 2012 10:04:08 AM UTC, comment #3:

Great, thanks.

The stuff about the ANSI-C style was just to say that since it's a standard, it's likely to be consistent across different shells. It also has much simpler rules, I think. I don't know how many older shells support it though. If you're interested, it's what I use for my python `bash_escape` mini library:

https://github.com/gfxmonk/bash-escape/blob/master/bash_escape.py

Tim Cuthbertson <gfxmonk>
Project Member
Mon 09 Jan 2012 11:12:21 PM UTC, comment #2:

Fixed in [3009913].

Ole Tange <tange>
Project Administrator
Mon 09 Jan 2012 02:37:01 PM UTC, comment #1:

That seems to be a general bug (not just zsh):

touch foo1
parallel ls ::: 'foo[13]'

Should give:

ls: cannot access foo[13]: No such file or directory

But gives:

foo1

I am not sure what you mean by the ANSI-C style quoting, and it is also unclear to me whether that will work better or worse on old shells.

Ole Tange <tange>
Project Administrator
Mon 09 Jan 2012 10:36:13 AM UTC, original submission:

a zsh session follows:

$ touch 'foo[1]'

$ ls -l
-rw-rw-r-- 1 tim tim 0 2012-01-09 21:08 foo[1]

$ parallel ls ::: 'foo[1]'
zsh:1: no matches found: foo[1]

$ ls -1 | parallel ls
zsh:1: no matches found: foo[1]

It looks like the shell quoting isn't escaping '[]' properly, although I can't tell exactly what the problem is (i.e what shell string it's trying to execute).

Looking at the shell_quote function, I wonder if you've considered the ANSI-C style of quoting, that is $'c-style-string':
http://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
Chances are it's more consistently supported across similar shells.

You may have already thought of this, and there may be a good reason not to - but I thought I'd point it out just in case.

Tim Cuthbertson <gfxmonk>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by tange (Posted a comment)
  • -unavailable- added by gfxmonk (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 09 Jan 2012 11:12:35 PM UTCtangeStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Mon 09 Jan 2012 02:58:00 PM UTCtangeSummaryshell_quote doesn\'t work in zsh with [] brackets=>shell_quote doesn't treats [] brackets correctly
    Mon 09 Jan 2012 02:37:01 PM UTCtangeStatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1