--- Python-3.1/Lib/subprocess.py.orig 2009年06月19日 22:34:30.000000000 +0200 +++ Python-3.1/Lib/subprocess.py 2009年08月12日 10:17:53.000000000 +0200 @@ -1025,7 +1025,7 @@ args = list(args) if shell: - args = ["/bin/sh", "-c"] + args + args = ["/bin/sh", "-c"] + [" ".join(args)] + args if executable is None: executable = args[0] --- Python-3.1/Lib/test/test_subprocess.py.orig 2009年03月29日 21:30:55.000000000 +0200 +++ Python-3.1/Lib/test/test_subprocess.py 2009年08月12日 10:13:25.000000000 +0200 @@ -631,6 +631,15 @@ env=newenv) self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple") + def test_shell_sequence_args(self): + # Run command through the shell (sequence) containing arguments + newenv = os.environ.copy() + newenv["FRUIT"] = "apple" + p = subprocess.Popen(["echo", "$FRUIT"], shell=1, + stdout=subprocess.PIPE, + env=newenv) + self.assertEqual(p.stdout.read().strip(), "apple") + def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy() @@ -732,6 +741,16 @@ env=newenv) self.assertNotEqual(p.stdout.read().find(b"physalis"), -1) + def test_shell_sequence_args(self): + # Run command through the shell (sequence) + newenv = os.environ.copy() + newenv["FRUIT"] = "physalis" + # this should invoke the variable-setting mode and not output anything + p = subprocess.Popen(["set", "FRUIT=silasyhp"], shell=1, + stdout=subprocess.PIPE, + env=newenv) + self.assertEqual(p.stdout.read().find("physalis"), -1) + def test_shell_string(self): # Run command through the shell (string) newenv = os.environ.copy()

AltStyle によって変換されたページ (->オリジナル) /