[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Idea: magic quoting
From: |
Ole Tange |
Subject: |
Idea: magic quoting |
Date: |
Wed, 11 Apr 2012 01:50:10 +0200 |
Quoting is a bitch. There is simply no correct way to Do What I Mean(tm).
Currently these do the same:
parallel echo {} \> {} ::: 1
parallel "echo {} > {}" ::: 1
And I think it makes good sense that you can choose to quote parts of
the expression if you want to. In the above case you want a space to
be given to the shell to evaluate.
But here:
parallel perl -e 'print "$$/{}\n"' ::: 1 # This does not work
you clearly intended it to be interpreted as:
parallel perl -e 'print\ \"\$\$/{}\\\n\"' ::: 1
I.e. the special chars in the 3rd argument should be quoted. -q will do that:
parallel -q perl -e 'print "$$/{}\n"' ::: 1 # This works
Much worse is:
parallel perl -e 'print "$$/{}\n"' \> {} ::: 1 # This does not work
Here you wanted some of the characters to be quoted and other not.
I am now thinking: Can we come up with a good heuristic for what
blocks the user wants quoted and what not? So:
parallel --magic-quote perl -e 'print "$$/{}\n"' \> {} ::: 1 # This
does not work
would do:
parallel perl -e 'print\ \"\$\$/{}\\\n\"' \> {} ::: 1
My initial idea was to find all blocks that have a space in them and
then quote those blocks unless there was only a single argument in
total (e.g. parallel "echo {} > {}" ::: 1)
Then I thought if we can do better by including all special shell
characters if they were not alone, so this would also work:
parallel --magic-quote perl -e 'print"$$/{}\n"' \> {} ::: 1 # Note
the missing space after print
But how would we then deal with: >{} or >>{}
It is not clear to me if it is possible to make a better guess than
now, but maybe you have a good idea for a heuristic.
/Ole
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Idea: magic quoting,
Ole Tange <=