Create a gist now

Instantly share code, notes, and snippets.

@andydude /echo.rs
Last active Dec 17, 2015

What would you like to do?
POSIX echo
fn main() {
let mut newline = true;
let mut arguments = os::args();
arguments.shift();
if arguments[0] == ~"-n" {
arguments.shift();
newline = false;
}
for arguments.eachi |argi, &argument| {
print(argument);
if argi == arguments.len() - 1 {
if newline {
print("\n");
}
} else {
print(" ");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment