From: Junio C Hamano Date: Sat, 5 Feb 2022 17:42:29 +0000 (-0800) Subject: Merge branch 'jh/p4-spawning-external-commands-cleanup' X-Git-Tag: v2.36.0-rc0~191 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=391d85d78db0b32712ab577fa701cc2856622e7e;p=thirdparty%2Fgit.git Merge branch 'jh/p4-spawning-external-commands-cleanup' * jh/p4-spawning-external-commands-cleanup: git-p4: don't print shell commands as python lists git-p4: pass command arguments as lists instead of using shell git-p4: don't select shell mode using the type of the command argument --- 391d85d78db0b32712ab577fa701cc2856622e7e diff --cc git-p4.py index ab3822696c,465ed16b25..47ad2d6409 --- a/git-p4.py +++ b/git-p4.py @@@ -400,23 -383,22 +395,22 @@@ def p4_has_move_command() # assume it failed because @... was invalid changelist return True - def system(cmd, ignore_error=False): - expand = not isinstance(cmd, list) + def system(cmd, ignore_error=False, *k, **kw): if verbose: - sys.stderr.write("executing %s\n" % str(cmd)) - retcode = subprocess.call(cmd, shell=expand) + sys.stderr.write("executing {}\n".format( + ' '.join(cmd) if isinstance(cmd, list) else cmd)) + retcode = subprocess.call(cmd, *k, **kw) if retcode and not ignore_error: - raise CalledProcessError(retcode, cmd) + raise subprocess.CalledProcessError(retcode, cmd) return retcode - def p4_system(cmd): + def p4_system(cmd, *k, **kw): """Specifically invoke p4 as the system command. """ real_cmd = p4_build_cmd(cmd) - expand = not isinstance(real_cmd, list) - retcode = subprocess.call(real_cmd, shell=expand) + retcode = subprocess.call(real_cmd, *k, **kw) if retcode: - raise CalledProcessError(retcode, real_cmd) + raise subprocess.CalledProcessError(retcode, real_cmd) def die_bad_access(s): die("failure accessing depot: {0}".format(s.rstrip()))