summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2007-04-20 15:15:08 +0000
committerChristian Schneider2007-04-20 15:15:08 +0000
commitf698a543363d4e106b77178c501785dbe3517331 (patch)
treea21eb242b8922d5771ed27b74e6d7243a6f8e357
parentd35165fea764bc2a1b32b979b1797a4ea4da249f (diff)
downloaditools-f698a543363d4e106b77178c501785dbe3517331.tar.gz
itools-f698a543363d4e106b77178c501785dbe3517331.tar.bz2
itools-f698a543363d4e106b77178c501785dbe3517331.zip
First scalar (command name) and option names are not quoted (but values are)
-rw-r--r--it.class11
1 files changed, 6 insertions, 5 deletions
diff --git a/it.class b/it.class
index 3c5df40..a70d587 100644
--- a/it.class
+++ b/it.class
@@ -275,8 +275,9 @@ function filter_keys($array, $keys)
/**
- * Construct shell command, log it, execute it and return output as string. Options ONLY allowed in assoc arrays
- * @param varargs: scalars for cmd and arguments, assoc arrays to specify opts and opt values, "-q"=>true for opts without args
+ * Construct shell command, log it, execute it and return output as string. Options ONLY allowed in assoc arrays.
+ * First scalar (usually command name) is not quoted, option names are not quoted (but option values are).
+ * @param varargs: scalars for cmd and arguments, assoc arrays to specify opts and opt values, '-q' => true for opts without args
* @return output of command. shell errors not detectable, see error_log in /www/server/logs
*/
function exec(/* ... */)
@@ -291,11 +292,11 @@ function exec(/* ... */)
if (it::match('^-', $val))
it::fatal("leading - in value");
else if ($val === true || $val === false || $val === null)
- $parts[] = $val ? escapeshellarg($key) : "";
+ $parts[] = $val ? $key : "";
else if (is_int($key))
- $parts[] = escapeshellarg($val);
+ $parts[] = $parts ? escapeshellarg($val) : $val;
else
- $parts[] = escapeshellarg($key) . " " . escapeshellarg($val);
+ $parts[] = "$key " . escapeshellarg($val);
}
}