note 98580 modified in function.escapeshellcmd by danbrown

From: Date: Fri, 25 Jun 2010 15:05:52 +0000
Subject: note 98580 modified in function.escapeshellcmd by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170429@lists.php.net to get a copy of this message
Mind it does not escape ! (exclamation mark). So if you want to i.e. printf() commands for later use in shell (i.e. by pasting to the console) you need to escape all exclamation marks or shell will try to process ! as history reference. This approach shall suffice: <?php $scaped = str_replace('!', '\!', escapeshellarg( $str ) ); ?> --was-- Mind it does not escape ! (exclamation mark). So if you want to i.e. printf() commands for later use in shell (i.e. by pasting to the console) you need to escape all exclamation marks or shell will try to process ! as history reference. This approach shall suffice: $scaped = str_replace('!', '\!', escapeshellarg( $str ) ); http://php.net/manual/en/function.escapeshellcmd.php

« previous php.notes (#170429) next »