奇怪子行为
问题描述:
subprocess.call(["find", ".", "-exec", "sh", "-c", "echo testFirst", ";"])
subprocess.call(["find", ".", "-exec", "sh", "-c", "echo testSecond", ";"], shell=True)
subprocess.call(["find . -exec sh -c 'echo testThird' \\;"], shell=True)
subprocess.call(["find", ".", "-exec", "sh", "-c", "touch testFirst", ";"])
subprocess.call(["find", ".", "-exec", "sh", "-c", "touch testSecond", ";"], shell=True)
subprocess.call(["find . -exec sh -c 'touch testThird' \\;"], shell=True)
产出如下:奇怪子行为
testFirst
testFirst
testFirst
.
./test.py
./data
testThird
testThird
testThird
.
./test.py
./testFirst
./data
而且只有testFirst
和testThird
文件被创建。
行为的解释是什么?
我会假设输出为testFirst
,testSecond
,testThird
以及正在创建的三个文件。
为什么你需要前4个参数呢? –
这不是我的实际代码,我只是缩小范围来证明问题。 –