-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
batch/backupdb defaults to --single-transaction
- Loading branch information
Showing
4 changed files
with
78 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
// subprocess.php -- Helper class for subprocess running | ||
// Copyright (c) 2006-2024 Eddie Kohler; see LICENSE. | ||
|
||
class Subprocess { | ||
/** @param string $word | ||
* @return string */ | ||
static function shell_quote_light($word) { | ||
if (preg_match('/\A[-_.,:+\/a-zA-Z0-9][-_.,:=+\/a-zA-Z0-9~]*\z/', $word)) { | ||
return $word; | ||
} | ||
return escapeshellarg($word); | ||
} | ||
|
||
/** @param list<string> $args | ||
* @return string */ | ||
static function shell_quote_args($args) { | ||
$s = []; | ||
foreach ($args as $word) { | ||
$s[] = self::shell_quote_light($word); | ||
} | ||
return join(" ", $s); | ||
} | ||
|
||
/** @param list<string> $args | ||
* @return list<string>|string */ | ||
static function args_to_command($args) { | ||
if (PHP_VERSION_ID < 70400) { | ||
return self::shell_quote_args($args); | ||
} | ||
return $args; | ||
} | ||
} |