forked from Spencer/math_shell
Compare commits
2 Commits
push-lnwls
...
b415be3ddc
| Author | SHA1 | Date | |
|---|---|---|---|
| b415be3ddc | |||
| 9a1d2ef586 |
16
src/main.zig
16
src/main.zig
@@ -122,11 +122,9 @@ fn mathTest(rand: Random, limit: i32, iteration: u32) !bool {
|
||||
|
||||
defer {
|
||||
print("Calculating", .{});
|
||||
for (0..3) |_| {
|
||||
for (1..4) |_| {
|
||||
print(".", .{});
|
||||
if (comptime builtin.mode != .Debug) {
|
||||
sleep(2 * 1000 * 1000 * 1000);
|
||||
}
|
||||
std.Thread.sleep(2 * 1000 * 1000 * 1000);
|
||||
}
|
||||
print("\n", .{});
|
||||
}
|
||||
@@ -163,7 +161,6 @@ fn cdFn(shell_state: *ShellState, command: [][]const u8, allocator: Allocator) !
|
||||
const old_pwd = env_map.get("OLDPWD");
|
||||
const home = env_map.get("HOME");
|
||||
defer allocator.free(pwd);
|
||||
var buf: [fs.max_path_bytes]u8 = undefined;
|
||||
var err: ?anyerror = null;
|
||||
|
||||
var target: ?[]const u8 = null;
|
||||
@@ -171,12 +168,6 @@ fn cdFn(shell_state: *ShellState, command: [][]const u8, allocator: Allocator) !
|
||||
if (home) |h| {
|
||||
target = h;
|
||||
}
|
||||
} else if (command[1][0] == '~') {
|
||||
if (home) |h| {
|
||||
const numReplacements = mem.replace(u8, command[1], "~", h, &buf);
|
||||
const len = command[1].len - numReplacements + (numReplacements * h.len);
|
||||
target = buf[0..len];
|
||||
}
|
||||
} else if (eql(u8, command[1], "-")) {
|
||||
if (old_pwd) |old| {
|
||||
target = old;
|
||||
@@ -185,6 +176,7 @@ fn cdFn(shell_state: *ShellState, command: [][]const u8, allocator: Allocator) !
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
var buf: [fs.max_path_bytes]u8 = undefined;
|
||||
target = cwd.realpath(command[1], &buf) catch |e| blk: {
|
||||
err = e;
|
||||
break :blk null;
|
||||
@@ -309,8 +301,6 @@ const tokenizeAny = mem.tokenizeAny;
|
||||
|
||||
const process = std.process;
|
||||
|
||||
const sleep = std.Thread.sleep;
|
||||
|
||||
const Random = std.Random;
|
||||
const ArrayList = std.ArrayList;
|
||||
const StaticStringMap = std.static_string_map.StaticStringMap;
|
||||
|
||||
Reference in New Issue
Block a user