
On 2 May 2012 16:49, Chris Samuel <chris@csamuel.org> wrote:
If I run that script with dash on Ubuntu it looks fine:
It *looks* fine. Is it really fine though? I suspect not. In fact, I think the results are identical, just the debug information is different. Try this test script: --- cut --- #!/bin/sh -ex a='aaa bbb "ccc ddd"' cat $a --- cut --- On Ubuntu I 11.10 I get: --- cut --- + a=aaa bbb "ccc ddd" + cat aaa bbb "ccc ddd" cat: aaa: No such file or directory cat: bbb: No such file or directory cat: "ccc: No such file or directory cat: ddd": No such file or directory --- cut --- Not that the quotes inside the variable don't mean anything. Just another character. The is because the quotes are parsed on the command line *before* the variable is expanded. On RHEL6 I get: --- cut --- tsm ~ # ./test + a='aaa bbb "ccc ddd"' + cat aaa bbb '"ccc' 'ddd"' cat: aaa: No such file or directory cat: bbb: No such file or directory cat: "ccc: No such file or directory cat: ddd": No such file or directory --- cut --- For comparison, zsh is somewhat different: --- cut --- +./test:3> a='aaa bbb "ccc ddd"' +./test:4> cat 'aaa bbb "ccc ddd"' cat: aaa bbb "ccc ddd": No such file or directory --- cut --- Not that the debug output is different, however the results are exactly the same. Apologies if this has already been mentioned, I am not reading this thread in order. Also apologies for my hacked way of showing how the arguments are really split up :-) -- Brian May <brian@microcomaustralia.com.au>