From bc569f8ef0bc4cda3b812317a1aff250d23b1a7c Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Thu, 22 Feb 2024 20:35:23 -0300 Subject: [PATCH] Fix dev off when environment is not active And also make sure to pass rm -f as some people alias rm to rm -i. --- src/modes/internal.activate.ts | 2 +- src/modes/shellcode.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modes/internal.activate.ts b/src/modes/internal.activate.ts index 316ef6d6..22feded9 100644 --- a/src/modes/internal.activate.ts +++ b/src/modes/internal.activate.ts @@ -95,7 +95,7 @@ export default async function(dir: Path, { powder, ...opts }: { powder: PackageR env ${off_string} if [ "$1" != --shy ]; then - rm "${persistence}" + rm -f "${persistence}" fi unset -f _pkgx_dev_off _pkgx_should_deactivate_devenv diff --git a/src/modes/shellcode.ts b/src/modes/shellcode.ts index bbfd4aeb..df0d18bd 100644 --- a/src/modes/shellcode.ts +++ b/src/modes/shellcode.ts @@ -55,7 +55,7 @@ export default function() { ${sh} "${tmp}/shellcode/x.$$" unset foo fi - rm "${tmp}/shellcode/"?.$$ + rm -f "${tmp}/shellcode/"?.$$ else echo "pkgx: nothing to run" >&2 return 1 @@ -90,7 +90,12 @@ export default function() { dev() { if [ "$1" = 'off' ]; then - _pkgx_dev_off + if type _pkgx_dev_off >/dev/null 2>&1; then + _pkgx_dev_off + else + echo 'dev: environment not active' >&2 + return 1 + fi elif type _pkgx_dev_off >/dev/null 2>&1; then echo 'dev: environment already active' >&2 return 1