Pārlūkot izejas kodu

~/.bin/up.rs: A version of up in Rust.

This should be smarter, shorter, sweeter. Or maybe the advantages of
advanced languages are not so apparent in small examples? Except small
examples are what makes them look wonderful. So small applied examples
are no good for them?

Mhh, that's definitively something to play with.
Lucas Stadler 12 gadi atpakaļ
vecāks
revīzija
67ce524af3
1 mainītis faili ar 15 papildinājumiem un 0 dzēšanām
  1. 15 0
      .bin/up.rs

+ 15 - 0
.bin/up.rs

@ -0,0 +1,15 @@
1
fn main() {
2
	let path = copy os::args()[1];
3
	let mut cwd = Path("");
4
	while cwd != Path("/") {
5
		cwd = os::getcwd();
6
		if Path(path).exists() {
7
			io::println(cwd.to_str());
8
			return;
9
		} else {
10
			os::change_dir(&Path(".."));
11
		}
12
	}
13
14
	os::set_exit_status(1);
15
}