fix(posix): use subshell on cd entry, nix trailing cd

This commit is contained in:
AJ ONeal
2022-08-21 06:36:40 +00:00
parent be05abb043
commit 5053d7064f
6 changed files with 259 additions and 249 deletions

View File

@@ -116,9 +116,10 @@ __webi_main() {
fi
set -e
pushd "\$WEBI_BOOT" 2>&1 > /dev/null
(
cd "\$WEBI_BOOT" 2>&1 > /dev/null
bash "\$my_package-bootstrap.sh"
popd 2>&1 > /dev/null
)
rm -rf "\$WEBI_BOOT"

View File

@@ -1,15 +1,16 @@
#!/bin/bash
# For installing from the extracted package tmp directory
pkg_install() {
cd "$WEBI_TMP" 2>&1 > /dev/null
(
cd "$WEBI_TMP" 2>&1 > /dev/null
if [ -n "$(command -v rsync 2> /dev/null | grep rsync)" ]; then
rsync -Krl ./xmpl*/ "$pkg_src/" 2> /dev/null
else
cp -Hr ./xmpl*/* "$pkg_src/" 2> /dev/null
cp -Hr ./xmpl*/.* "$pkg_src/" 2> /dev/null
fi
rm -rf ./xmpl*
if [ -n "$(command -v rsync 2> /dev/null | grep rsync)" ]; then
rsync -Krl ./xmpl*/ "$pkg_src/" 2> /dev/null
else
cp -Hr ./xmpl*/* "$pkg_src/" 2> /dev/null
cp -Hr ./xmpl*/.* "$pkg_src/" 2> /dev/null
fi
rm -rf ./xmpl*
cd 2>&1 > /dev/null
)
}

View File

@@ -222,25 +222,26 @@ __bootstrap_webi() {
# detect which archives can be used
webi_extract() {
cd "$WEBI_TMP" > /dev/null 2>&1
if [ "tar" = "$WEBI_EXT" ]; then
echo "Extracting ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
tar xf "${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
elif [ "zip" = "$WEBI_EXT" ]; then
echo "Extracting ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
unzip "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" > __unzip__.log
elif [ "exe" = "$WEBI_EXT" ]; then
echo "Moving ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
mv "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" .
elif [ "xz" = "$WEBI_EXT" ]; then
echo "Inflating ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
unxz -c "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" > "$(basename "$WEBI_PKG_FILE")"
else
# do nothing
echo "Failed to extract ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
exit 1
fi
cd > /dev/null 2>&1
(
cd "$WEBI_TMP" > /dev/null 2>&1
if [ "tar" = "$WEBI_EXT" ]; then
echo "Extracting ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
tar xf "${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
elif [ "zip" = "$WEBI_EXT" ]; then
echo "Extracting ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
unzip "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" > __unzip__.log
elif [ "exe" = "$WEBI_EXT" ]; then
echo "Moving ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
mv "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" .
elif [ "xz" = "$WEBI_EXT" ]; then
echo "Inflating ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
unxz -c "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" > "$(basename "$WEBI_PKG_FILE")"
else
# do nothing
echo "Failed to extract ${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
exit 1
fi
)
}
# use 'pathman' to update $HOME/.config/envman/PATH.env
@@ -398,23 +399,26 @@ __bootstrap_webi() {
if [ -n "$(command -v pkg_pre_install)" ]; then pkg_pre_install; else webi_pre_install; fi
cd "$WEBI_TMP" > /dev/null 2>&1
echo "Installing to $pkg_src_cmd"
if [ -n "$(command -v pkg_install)" ]; then pkg_install; else webi_install; fi
chmod a+x "$pkg_src"
chmod a+x "$pkg_src_cmd"
cd > /dev/null 2>&1
(
cd "$WEBI_TMP" > /dev/null 2>&1
echo "Installing to $pkg_src_cmd"
if [ -n "$(command -v pkg_install)" ]; then pkg_install; else webi_install; fi
chmod a+x "$pkg_src"
chmod a+x "$pkg_src_cmd"
)
webi_link
_webi_enable_exec
cd "$WEBI_TMP" > /dev/null 2>&1
if [ -n "$(command -v pkg_post_install)" ]; then pkg_post_install; else webi_post_install; fi
cd > /dev/null 2>&1
(
cd "$WEBI_TMP" > /dev/null 2>&1
if [ -n "$(command -v pkg_post_install)" ]; then pkg_post_install; else webi_post_install; fi
)
cd "$WEBI_TMP" > /dev/null 2>&1
if [ -n "$(command -v pkg_done_message)" ]; then pkg_done_message; else _webi_done_message; fi
cd > /dev/null 2>&1
(
cd "$WEBI_TMP" > /dev/null 2>&1
if [ -n "$(command -v pkg_done_message)" ]; then pkg_done_message; else _webi_done_message; fi
)
echo ""
fi

View File

@@ -5,30 +5,31 @@ set -u
main() {
webi_download
cd ~/Downloads/webi 2>&1 > /dev/null
(
cd ~/Downloads/webi 2>&1 > /dev/null
if [ "Darwin" = "$(uname -s)" ]; then
curl -fsSL 'https://gist.githubusercontent.com/coolaj86/8c36d132250163011c83bad8284975ee/raw/5a291955813743c20c12ca2d35c7b1bb34f8aecc/create-bootable-installer-for-os-x-el-capitan.sh' -o create-bootable-installer-for-os-x-el-capitan.sh
bash create-bootable-installer-for-os-x-el-capitan.sh
else
curl -fsSL 'https://gist.githubusercontent.com/coolaj86/9834a45a6c21a41e8882698a00b55787/raw/c43061cd0c53ec675996f5cb66c7077e666aabd4/install-mac-tools.sh' -o install-mac-tools.sh
# TODO add xar to webinstall.dev
sudo apt install libz-dev # needed for xar
bash install-mac-tools.sh
echo "WARN: may need a restart for hfsplus to be recognized by the kernel"
if [ "Darwin" = "$(uname -s)" ]; then
curl -fsSL 'https://gist.githubusercontent.com/coolaj86/8c36d132250163011c83bad8284975ee/raw/5a291955813743c20c12ca2d35c7b1bb34f8aecc/create-bootable-installer-for-os-x-el-capitan.sh' -o create-bootable-installer-for-os-x-el-capitan.sh
bash create-bootable-installer-for-os-x-el-capitan.sh
else
curl -fsSL 'https://gist.githubusercontent.com/coolaj86/9834a45a6c21a41e8882698a00b55787/raw/c43061cd0c53ec675996f5cb66c7077e666aabd4/install-mac-tools.sh' -o install-mac-tools.sh
# TODO add xar to webinstall.dev
sudo apt install libz-dev # needed for xar
bash install-mac-tools.sh
echo "WARN: may need a restart for hfsplus to be recognized by the kernel"
curl -fsSL 'https://gist.github.com/coolaj86/04fd06560a8465a695337eb502f5b0e9/raw/0a06fb4dce91399d374d9a12958dabb48a9bd42a/empty.7400m.img.bz2' -o empty.7400m.img.bz2
curl -fsSL 'https://gist.github.com/coolaj86/04fd06560a8465a695337eb502f5b0e9/raw/0a06fb4dce91399d374d9a12958dabb48a9bd42a/empty.7400m.img.bz2' -o empty.7400m.img.bz2
curl -fsSL 'https://gist.githubusercontent.com/coolaj86/9834a45a6c21a41e8882698a00b55787/raw/c43061cd0c53ec675996f5cb66c7077e666aabd4/linux-create-bootable-macos-recovery-image.sh' -o linux-create-bootable-macos-recovery-image.sh
bash linux-create-bootable-macos-recovery-image.sh
fi
curl -fsSL 'https://gist.githubusercontent.com/coolaj86/9834a45a6c21a41e8882698a00b55787/raw/c43061cd0c53ec675996f5cb66c7077e666aabd4/linux-create-bootable-macos-recovery-image.sh' -o linux-create-bootable-macos-recovery-image.sh
bash linux-create-bootable-macos-recovery-image.sh
fi
mv ~/Downloads/webi/el-capitan.iso ~/Downloads/
echo ""
echo "Created ~/Downloads/el-capitan.iso"
echo ""
mv ~/Downloads/webi/el-capitan.iso ~/Downloads/
echo ""
echo "Created ~/Downloads/el-capitan.iso"
echo ""
cd 2>&1 > /dev/null
)
}
main

View File

@@ -23,9 +23,10 @@ __init_powershell() {
mv ./* "$pkg_src"
# symlink powershell to pwsh
cd "$pkg_src" > /dev/null
ln -s pwsh powershell
cd > /dev/null
(
cd "$pkg_src" > /dev/null
ln -s pwsh powershell
)
}
pkg_link() {

View File

@@ -4,191 +4,193 @@ set -u
__rmrf_local() {
if [ -d "${HOME}/.local/opt" ]; then
cd "${HOME}/.local/opt" 2>&1 > /dev/null
rm -rf \
arc \
archiver \
awless \
bat \
caddy \
chromedriver \
comrak \
curlie \
delta \
deno \
dotenv \
dotenv-linter \
fd \
ffmpeg \
fzf \
gh \
git-config-gpg \
git-gpg-init \
gitdeploy \
gitea \
gnupg \
goreleaser \
gpg \
gpg-pubkey \
gprox \
hexyl \
hugo \
iterm-color-schemes \
iterm-themes \
iterm-utils \
iterm2-color-schemes \
iterm2-themes \
iterm2-utils \
jq \
k9s \
keypairs \
kind \
koji \
kubectx \
kubens \
lf \
lsd \
mutagen \
myip \
nerd-font \
nerdfont \
node \
ots \
pandoc \
pathman \
prettier \
powershell \
pwsh \
rclone \
rg \
ripgrep \
rust.vim \
sass \
sclient \
sd \
serviceman \
setcap-netbind \
shellcheck \
shfmt \
ssh-pubkey \
ssh-utils \
syncthing \
vim-ale \
vim-essentials \
vim-lastplace \
vim-leader \
vim-nerdtree \
vim-prettier \
vim-rust \
vim-sensible \
vim-shell \
vim-shfmt \
vim-spell \
vim-viminfo \
vim-whitespace \
vps-myip \
vps-utils \
watchexec \
xz \
yq \
zoxide
# exceptions (may lose data)
#postgres \
#postgresql \
cd 2>&1 > /dev/null
cd "${HOME}/.local/bin" 2>&1 > /dev/null
rm -f \
arc \
archiver \
awless \
bat \
caddy \
chromedriver \
comrak \
curlie \
delta \
deno \
dotenv \
dotenv-linter \
fd \
ffmpeg \
fzf \
gh \
git-config-gpg \
git-gpg-init \
gitdeploy \
gitea \
gnupg \
goreleaser \
gpg \
gpg-pubkey \
gprox \
hexyl \
hugo \
iterm-color-schemes \
iterm-themes \
iterm-utils \
iterm2-color-schemes \
iterm2-themes \
iterm2-utils \
jq \
k9s \
keypairs \
kind \
koji \
kubectx \
kubens \
lf \
lsd \
mutagen \
myip \
nerd-font \
nerdfont \
node \
ots \
pandoc \
pathman \
prettier \
powershell \
pwsh \
rclone \
rg \
ripgrep \
rust.vim \
sass \
sclient \
sd \
serviceman \
setcap-netbind \
shellcheck \
shfmt \
ssh-pubkey \
ssh-utils \
syncthing \
vim-ale \
vim-essentials \
vim-go \
vim-lastplace \
vim-leader \
vim-nerdtree \
vim-prettier \
vim-rust \
vim-sensible \
vim-shell \
vim-shfmt \
vim-spell \
vim-viminfo \
vim-whitespace \
vps-myip \
vps-utils \
watchexec \
xz \
yq \
zoxide
# exceptions (may lose data)
#postgres \
#postgresql \
cd 2>&1 > /dev/null
(
cd "${HOME}/.local/opt" 2>&1 > /dev/null
rm -rf \
arc \
archiver \
awless \
bat \
caddy \
chromedriver \
comrak \
curlie \
delta \
deno \
dotenv \
dotenv-linter \
fd \
ffmpeg \
fzf \
gh \
git-config-gpg \
git-gpg-init \
gitdeploy \
gitea \
gnupg \
goreleaser \
gpg \
gpg-pubkey \
gprox \
hexyl \
hugo \
iterm-color-schemes \
iterm-themes \
iterm-utils \
iterm2-color-schemes \
iterm2-themes \
iterm2-utils \
jq \
k9s \
keypairs \
kind \
koji \
kubectx \
kubens \
lf \
lsd \
mutagen \
myip \
nerd-font \
nerdfont \
node \
ots \
pandoc \
pathman \
prettier \
powershell \
pwsh \
rclone \
rg \
ripgrep \
rust.vim \
sass \
sclient \
sd \
serviceman \
setcap-netbind \
shellcheck \
shfmt \
ssh-pubkey \
ssh-utils \
syncthing \
vim-ale \
vim-essentials \
vim-lastplace \
vim-leader \
vim-nerdtree \
vim-prettier \
vim-rust \
vim-sensible \
vim-shell \
vim-shfmt \
vim-spell \
vim-viminfo \
vim-whitespace \
vps-myip \
vps-utils \
watchexec \
xz \
yq \
zoxide
# exceptions (may lose data)
#postgres \
#postgresql \
)
(
cd "${HOME}/.local/bin" 2>&1 > /dev/null
rm -f \
arc \
archiver \
awless \
bat \
caddy \
chromedriver \
comrak \
curlie \
delta \
deno \
dotenv \
dotenv-linter \
fd \
ffmpeg \
fzf \
gh \
git-config-gpg \
git-gpg-init \
gitdeploy \
gitea \
gnupg \
goreleaser \
gpg \
gpg-pubkey \
gprox \
hexyl \
hugo \
iterm-color-schemes \
iterm-themes \
iterm-utils \
iterm2-color-schemes \
iterm2-themes \
iterm2-utils \
jq \
k9s \
keypairs \
kind \
koji \
kubectx \
kubens \
lf \
lsd \
mutagen \
myip \
nerd-font \
nerdfont \
node \
ots \
pandoc \
pathman \
prettier \
powershell \
pwsh \
rclone \
rg \
ripgrep \
rust.vim \
sass \
sclient \
sd \
serviceman \
setcap-netbind \
shellcheck \
shfmt \
ssh-pubkey \
ssh-utils \
syncthing \
vim-ale \
vim-essentials \
vim-go \
vim-lastplace \
vim-leader \
vim-nerdtree \
vim-prettier \
vim-rust \
vim-sensible \
vim-shell \
vim-shfmt \
vim-spell \
vim-viminfo \
vim-whitespace \
vps-myip \
vps-utils \
watchexec \
xz \
yq \
zoxide
# exceptions (may lose data)
#postgres \
#postgresql \
)
fi
}