Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14114412
D13519.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D13519.diff
View Options
diff --git a/src/console/format.php b/src/console/format.php
--- a/src/console/format.php
+++ b/src/console/format.php
@@ -183,31 +183,35 @@
* @return int|null Terminal width in characters, or null on failure.
*/
function phutil_console_get_terminal_width() {
- if (phutil_is_windows()) {
- // TODO: Figure out how to get this working in Windows.
- return null;
- }
+ static $width;
- $tmp = new TempFile();
+ if ($width === null) {
+ if (phutil_is_windows()) {
+ // TODO: Figure out how to get this working in Windows.
+ return null;
+ }
- // NOTE: We can't just execute this because it won't be connected to a TTY
- // if we do.
- $err = phutil_passthru('tput cols > %s', $tmp);
+ $tmp = new TempFile();
- if ($err) {
- return null;
- }
+ // NOTE: We can't just execute this because it won't be connected to a TTY
+ // if we do.
+ $err = phutil_passthru('tput cols > %s', $tmp);
- try {
- $cols = Filesystem::readFile($tmp);
- } catch (FilesystemException $ex) {
- return null;
- }
+ if ($err) {
+ return null;
+ }
- $cols = (int)$cols;
- if (!$cols) {
- return null;
+ try {
+ $cols = Filesystem::readFile($tmp);
+ } catch (FilesystemException $ex) {
+ return null;
+ }
+
+ $width = (int)$cols;
+ if (!$width) {
+ $width = null;
+ }
}
- return $cols;
+ return $width;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 29, 8:18 AM (21 h, 43 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6804514
Default Alt Text
D13519.diff (1 KB)
Attached To
Mode
D13519: Cache terminal width
Attached
Detach File
Event Timeline
Log In to Comment