1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 22:57:46 +00:00

Unspanned error (#267)

* unspanned errors

* hosts updater is now sudo-able
This commit is contained in:
Kamil 2022-07-28 10:07:02 +02:00 committed by GitHub
parent 391086a4f9
commit c8602b6765
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 6 deletions

View file

@ -20,9 +20,9 @@ def-env c [dir = ""] {
}
let complete_dir = if $complete_dir == "" {
error make {msg: "No such path"}
error make -u {msg: "No such path"}
} else if (($complete_dir | path expand | path type) != "dir") {
error make {msg: "Not a directory"}
error make -u {msg: "Not a directory"}
} else {
($complete_dir | path expand)
}

View file

@ -45,18 +45,19 @@ module hosts {
let TMP_FILE = ($TMP_FILE | append $BLACKLIST)
$TMP_FILE | save $OLD_FILE
$TMP_FILE | save /tmp/temphostsfile
if ($env.LAST_EXIT_CODE == 0) {
sudo mv /tmp/temphostsfile $OLD_FILE
echo "Done!"
} else {
error make {msg: "Something went wrong while overwriting the /etc/hosts file"}
error make -u {msg: "Something went wrong while overwriting the /etc/hosts file"}
}
}
} else {
echo "No updates available."
}
} else {
error make {msg: "Failed downloading the hosts file, try again."}
error make -u {msg: "Failed downloading the hosts file, try again."}
}
}
}

View file

@ -30,7 +30,7 @@ def fact [num: int] {
seq 2 $num | math product
}
} else {
error make {msg: "can only calculate non-negative integers"}
error make -u {msg: "can only calculate non-negative integers"}
}
}