Skip to content

Commit

Permalink
fish: Fix updating distrobox container with upd
Browse files Browse the repository at this point in the history
Introduce get_dev_img_esc() and use in more places, including upd to
look for the name of the container, rather than the image (because the
tag could disappear).

Signed-off-by: Nathan Chancellor <[email protected]>
  • Loading branch information
nathanchance committed Dec 22, 2023
1 parent cc1af30 commit dc5daeb
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fish/functions/dbxc.fish
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function dbxc -d "Shorthand for 'distrobox create'"
# If no image was specified, default to the one for the architecture
if not set -q img
set img $GHCR/(get_dev_img)
set name (string replace / - (get_dev_img))
set name (get_dev_img_esc)
end

set -a dbx_args -i $img
Expand Down
2 changes: 1 addition & 1 deletion fish/functions/dbxe.fish
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function dbxe -d "Shorthand for 'distrobox enter'"
end

if not set -q dbx_img
set dbx_img (string replace / - (get_dev_img))
set dbx_img (get_dev_img_esc)
end

if test (count $add_args) -gt 0
Expand Down
2 changes: 1 addition & 1 deletion fish/functions/dbxr.fish
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

function dbxr -d "Remove a distrobox container"
if test (count $argv) -eq 0
set targets (get_dev_img | string replace / -)
set targets (get_dev_img_esc)
else
set targets $argv
end
Expand Down
7 changes: 7 additions & 0 deletions fish/functions/get_dev_img_esc.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env fish
# SPDX-License-Identifier: MIT
# Copyright (C) 2023 Nathan Chancellor

function get_dev_img_esc -d "Replace '/' in value from get_dev_img() with '-'"
string replace / - (get_dev_img)
end
2 changes: 1 addition & 1 deletion fish/functions/upd.fish
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function upd -d "Runs the update command for the current distro or downloads/upd
print_error "Unknown OS! Cannot upgrade using 'upd'. Modify 'get_distro' to support this distro."
return 1
end
if has_container_manager; and dbx list &| grep -q (get_dev_img)
if has_container_manager; and dbx list &| grep -q (get_dev_img_esc)
dbxe -- "fish -c 'upd -y'"
end
if command -q mac
Expand Down

0 comments on commit dc5daeb

Please sign in to comment.