From bdd25226a83d1c16c8c47c105b0a0e92254d5b93 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Thu, 21 Mar 2024 14:36:41 -0700 Subject: [PATCH] do the private-or-subshell dance for `maybesudo` --- sh/maybesudo | 7 ++++--- sh/pippy | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sh/maybesudo b/sh/maybesudo index 253b713..2ae70e6 100755 --- a/sh/maybesudo +++ b/sh/maybesudo @@ -4,7 +4,7 @@ # YES_DASH # YES_ASH -maybesudo_() ( ### @- +__maybesudo() { ### @maybesudo ### mimic certain features of `sudo` for systems without it installed. ### as it stands, this mostly just handles some environment variables. ### @@ -113,6 +113,7 @@ maybesudo_() ( ### @- fi env "$@" -) +} -[ -n "${preload+-}" ] || maybesudo_ "$@" +maybesudo_()(__maybesudo "$@") +[ -n "${preload+-}" ] || __maybesudo "$@" diff --git a/sh/pippy b/sh/pippy index 55031d6..41b3a87 100755 --- a/sh/pippy +++ b/sh/pippy @@ -7,7 +7,7 @@ pippy() { ### @- ### install Python packages using pip, ### but only update their dependencies as required. - ### this uses [`maybesudo`](#maybesudo_-shmaybesudo) internally. + ### this uses [`maybesudo`](#maybesudo) internally. if [ -s ~/work/automamba ]; then ~/work/automamba --pip install --upgrade --upgrade-strategy only-if-needed --dry-run "$@" confirm || return