Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
extrautils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nagy Tibor
extrautils
Commits
5f016076
Unverified
Commit
5f016076
authored
Jun 02, 2018
by
Jeremy Soller
Committed by
GitHub
Jun 02, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #42 from xTibor/fix-watch
Fix watch on Redox
parents
4b0d9999
8b7a0ff1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
src/bin/watch.rs
src/bin/watch.rs
+8
-8
No files found.
src/bin/watch.rs
View file @
5f016076
...
...
@@ -6,7 +6,7 @@ extern crate extra;
extern
crate
termion
;
use
std
::{
cmp
,
str
,
thread
};
use
std
::
env
::
args
;
use
std
::
env
::
{
self
,
args
}
;
use
std
::
io
::{
self
,
Write
,
Read
};
use
std
::
process
::{
self
,
Command
,
Stdio
};
use
std
::
time
::
Duration
;
...
...
@@ -21,7 +21,7 @@ NAME
watch - execute a program periodically, showing output fullscreen
SYNOPSIS
watch [-h | --help] command
watch [-h | --help]
[-n N | --interval N]
command
DESCRIPTION
Runs command repeatedly, displaying its output and errors. This allows you to watch the program
...
...
@@ -103,6 +103,8 @@ fn main() {
fn
run
<
W
:
IntoRawMode
>
(
command
:
String
,
interval
:
u64
,
stdout
:
W
)
->
std
::
io
::
Result
<
()
>
{
let
title
=
format!
(
"Every {}s: {}"
,
interval
,
command
);
let
shell
=
env
::
var
(
"SHELL"
)
.unwrap_or
(
String
::
from
(
"sh"
));
let
mut
stdout
=
stdout
.into_raw_mode
()
?
;
let
(
w
,
h
)
=
terminal_size
()
?
;
...
...
@@ -112,13 +114,11 @@ fn run<W: IntoRawMode>(command: String, interval: u64, stdout: W) -> std::io::Re
'watching
:
loop
{
write!
(
stdout
,
"{}{}{}"
,
clear
::
All
,
style
::
Reset
,
cursor
::
Goto
(
1
,
1
))
?
;
let
child
=
Command
::
new
(
"sh"
)
.arg
(
"-c"
)
.arg
(
&
command
)
let
child
=
Command
::
new
(
&
shell
)
.arg
(
"-c"
)
.arg
(
&
command
)
.stdin
(
Stdio
::
null
())
.stdout
(
Stdio
::
piped
())
.stderr
(
Stdio
::
piped
())
.spawn
()
?
;
let
mut
output
=
String
::
new
();
if
let
Some
(
mut
stdout
)
=
child
.stdout
{
stdout
.read_to_string
(
&
mut
output
)
?
;
}
.output
()
?
;
let
output
=
String
::
from_utf8_lossy
(
&
child
.stdout
);
let
mut
y
=
0
;
for
line
in
output
.lines
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment