summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2007-04-17 16:51:37 +0000
committerUrban Müller2007-04-17 16:51:37 +0000
commitac22dbe4cca560cf1f4af54e952a459052101f80 (patch)
treee7ecf0e1752334af0c93d9ff2f3411dbd80c9339
parent4a2ae94f1dfe091b33c4fcc1e03e64862cc943bc (diff)
downloaditools-ac22dbe4cca560cf1f4af54e952a459052101f80.tar.gz
itools-ac22dbe4cca560cf1f4af54e952a459052101f80.tar.bz2
itools-ac22dbe4cca560cf1f4af54e952a459052101f80.zip
handle opts without args
-rw-r--r--it.class10
1 files changed, 7 insertions, 3 deletions
diff --git a/it.class b/it.class
index c3841d3..3c5df40 100644
--- a/it.class
+++ b/it.class
@@ -275,8 +275,8 @@ function filter_keys($array, $keys)
/**
- * Construct shell command, log it, execute it and return output as string.
- * @param varargs: scalars for cmd and arguments, assoc arrays to specify opts and opt values
+ * 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
* @return output of command. shell errors not detectable, see error_log in /www/server/logs
*/
function exec(/* ... */)
@@ -290,8 +290,12 @@ function exec(/* ... */)
{
if (it::match('^-', $val))
it::fatal("leading - in value");
+ else if ($val === true || $val === false || $val === null)
+ $parts[] = $val ? escapeshellarg($key) : "";
+ else if (is_int($key))
+ $parts[] = escapeshellarg($val);
else
- $parts[] = (is_int($key) ? "" : escapeshellarg($key) . " ") . escapeshellarg($val);
+ $parts[] = escapeshellarg($key) . " " . escapeshellarg($val);
}
}