Skip to content

Commit

Permalink
feat: simplify sudo condition in switch.fish to check user ID directly
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikoTan committed Oct 30, 2024
1 parent 2a47477 commit fb19467
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions switch.fish
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ set cmd "nixos-rebuild switch"
set dry_run false
set host (uname -n)

set should_sudo (test (id -u) -ne 0)

for arg in $argv
switch $arg
case '-h' '--help'
Expand All @@ -47,7 +45,7 @@ if test $dry_run = true
set cmd "nixos-rebuild test"
end

if test $should_sudo = true
if test (id -u) -ne 0
set cmd "sudo $cmd"
end

Expand Down

0 comments on commit fb19467

Please sign in to comment.