Borek Bernard
Borek Bernard

Reputation: 53241

PHP: escapeshellarg() to which I can pass the desired escaping convention

I'm looking for a PHP function similar to escapeshellarg() that would allow me to pass the OS for which the escaping should be done as a parameter.

My use case is this: I am on Windows where escapeshellarg() surrounds the arg with double quotes. However, the command being constructed will eventually be run on a Linux system via SSH where single quotes must be used. So I'm looking for something like:

$escapedArg = escapeshellarg($arg, LINUX_OS);

Upvotes: 3

Views: 100

Answers (1)

Borek Bernard
Borek Bernard

Reputation: 53241

I found what I needed in Drush, specifically in these functions:

  • _drush_escapeshellarg_linux()
  • _drush_escapeshellarg_windows()

Upvotes: 1

Related Questions