mirror of
https://git.pionaiki.com/marta/nixie.git
synced 2025-10-09 05:47:21 +00:00
Error handling ig
This commit is contained in:
parent
4718468fdb
commit
acf18ad3ba
1 changed files with 8 additions and 3 deletions
11
nixie
11
nixie
|
@ -12,6 +12,11 @@ QUIT () {
|
|||
exit
|
||||
}
|
||||
|
||||
QUIT1 () {
|
||||
popd > /dev/null
|
||||
exit 1
|
||||
}
|
||||
|
||||
CHOOSE_CASE () {
|
||||
echo -e -n "${IPurple}Build changes? ${Purple}Yes/Preview/Edit/Restore/Quit. (y/p/e/r/q):${NC} "
|
||||
|
||||
|
@ -33,12 +38,12 @@ BUILD () {
|
|||
case $CHOICE in
|
||||
[nN]* ) echo -e -n "[ ${Red}cancelled${NC} ] " && CHOOSE_CASE ;;
|
||||
*)
|
||||
git add .
|
||||
sudo git add .
|
||||
echo -e "${IPurple}Rebuilding NixOS...${NC}"
|
||||
sudo nixos-rebuild switch
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "[ ${Bred}error${NC} ] ${Red}Rebuilding NixOS failed.${NC}"
|
||||
QUIT
|
||||
echo -e "[ ${Red}error${NC} ] ${Red}Rebuilding NixOS failed.${NC}"
|
||||
QUIT1
|
||||
fi
|
||||
echo -e "${IPurple}Committing the changes...${NC}"
|
||||
sudo git commit --no-status -am "$(sudo nixos-rebuild list-generations | grep current | sed 's/ .*//')"
|
||||
|
|
Loading…
Add table
Reference in a new issue