mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-21 15:55:36 +08:00
Use redirect instead
This commit is contained in:
@@ -47,17 +47,14 @@ class SourcePatcher
|
|||||||
}
|
}
|
||||||
$patch_cwd = FileSystem::convertPath($cwd);
|
$patch_cwd = FileSystem::convertPath($cwd);
|
||||||
$patch_arg = $patch_str;
|
$patch_arg = $patch_str;
|
||||||
if (PHP_OS_FAMILY === 'Windows') {
|
|
||||||
$patch_arg = FileSystem::convertWinPathToMinGW($patch_arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detect if patch is already applied (reverse detection)
|
// Detect if patch is already applied (reverse detection)
|
||||||
$detect_reverse = !$reverse;
|
$detect_reverse = !$reverse;
|
||||||
$cd_cmd = (PHP_OS_FAMILY === 'Windows' ? 'cd /d ' : 'cd ') . escapeshellarg($patch_cwd);
|
$cd_cmd = (PHP_OS_FAMILY === 'Windows' ? 'cd /d ' : 'cd ') . escapeshellarg($patch_cwd);
|
||||||
$detect_cmd = $cd_cmd
|
$detect_cmd = $cd_cmd
|
||||||
. ' && patch --dry-run -p1 -s -f'
|
. ' && patch --dry-run -p1 -s -f'
|
||||||
. ' -i ' . escapeshellarg($patch_arg)
|
|
||||||
. ($detect_reverse ? ' -R' : '')
|
. ($detect_reverse ? ' -R' : '')
|
||||||
|
. ' < ' . escapeshellarg($patch_arg)
|
||||||
. ' > ' . (PHP_OS_FAMILY === 'Windows' ? 'NUL' : '/dev/null') . ' 2>&1';
|
. ' > ' . (PHP_OS_FAMILY === 'Windows' ? 'NUL' : '/dev/null') . ' 2>&1';
|
||||||
exec($detect_cmd, $output, $detect_status);
|
exec($detect_cmd, $output, $detect_status);
|
||||||
|
|
||||||
@@ -69,8 +66,8 @@ class SourcePatcher
|
|||||||
// Apply patch
|
// Apply patch
|
||||||
$apply_cmd = $cd_cmd
|
$apply_cmd = $cd_cmd
|
||||||
. ' && patch -p1'
|
. ' && patch -p1'
|
||||||
. ' -i ' . escapeshellarg($patch_arg)
|
. ($reverse ? ' -R' : '')
|
||||||
. ($reverse ? ' -R' : '');
|
. ' < ' . escapeshellarg($patch_arg);
|
||||||
|
|
||||||
exec($apply_cmd, $apply_output, $apply_status);
|
exec($apply_cmd, $apply_output, $apply_status);
|
||||||
if ($apply_status !== 0) {
|
if ($apply_status !== 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user