:-'Generic Commit'

This commit is contained in:
Your Name 2025-05-28 20:40:20 +12:00
parent 0fc886bbf7
commit dae98a3686
2 changed files with 44 additions and 35 deletions

View File

@ -4,6 +4,15 @@ set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
_die() {
echo -e "Error: $1" >&2
exit 1
}
#----------------------------------------------------------------------------------------------------------
# Headers on Host (Native)
#----------------------------------------------------------------------------------------------------------
@ -141,34 +150,9 @@ function install_openssl_musl() {
# MUSL CROSS COMPILERS
# ----------------------------------------------------------------------------------------------------------
function installmusl() {
echo "Installing musl toolchain"
# Set install directory
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
USER_HOME=$(eval echo "~${SUDO_USER}")
else
USER_HOME="$HOME"
fi
INSTALL_DIR="$USER_HOME/.musl-cross"
mkdir -p "$INSTALL_DIR"
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
function install_musl_cross() {
local TOOLCHAIN="$1"
local MUSL_CC_URL="https://musl.cc"
if [ ! -d "$INSTALL_DIR/$TOOLCHAIN" ]; then
echo "Downloading $TOOLCHAIN musl cross toolchain..."
wget -nc -O "$TMPDIR/$TOOLCHAIN.tgz" "$MUSL_CC_URL/$TOOLCHAIN.tgz"
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/$TOOLCHAIN.tgz"
fi
}
function check_path() {
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
local BASHRC="$USER_HOME/.bashrc"
local BASHRC="${USER_HOME}/.bashrc"
local TOOLCHAIN="$1"
local MUSL_PATH="$INSTALL_DIR/$TOOLCHAIN/bin"
if ! echo "$PATH" | grep -q "$MUSL_PATH"; then
@ -185,9 +169,33 @@ function installmusl() {
echo "You should run 'source ~/.bashrc' to update your PATH"
fi
fi
}
function install_musl_cross() {
local TOOLCHAIN="$1"
local MUSL_CC_URL="https://musl.cc"
if [ ! -d "$INSTALL_DIR/$TOOLCHAIN" ]; then
echo "Downloading $TOOLCHAIN musl cross toolchain..."
wget -nc -O "$TMPDIR/$TOOLCHAIN.tgz" "$MUSL_CC_URL/$TOOLCHAIN.tgz"
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/$TOOLCHAIN.tgz"
fi
}
function installmusl() {
echo "Installing musl toolchain"
# Set install directory
if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then
USER_HOME=$(eval echo "~${SUDO_USER}")
else
USER_HOME="$HOME"
fi
INSTALL_DIR="$USER_HOME/.musl-cross"
mkdir -p "$INSTALL_DIR"
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
TOOLCHAIN_LIST=(
"aarch64-linux-musl-cross"
"x86_64-linux-musl-cross"
@ -203,7 +211,6 @@ function installmusl() {
}
#----------------------------------------------------------------------------------------------------------
# Main
#----------------------------------------------------------------------------------------------------------

View File

@ -100,7 +100,9 @@ void DropshellScriptManager::addAutocomplete(const std::string& toolName) {
std::string funcDef;
funcDef += blockStart + "\n";
funcDef += funcName + "() {\n";
funcDef += " COMPREPLY=($(" + toolName + " autocomplete \"${COMP_WORDS[@]:1}\"))\n";
funcDef += " local cur=\"${COMP_WORDS[COMP_CWORD]}\"\n";
funcDef += " mapfile -t completions < <(" + toolName + " autocomplete \"${COMP_WORDS[@]:1:${COMP_CWORD}-1}\")\n";
funcDef += " mapfile -t COMPREPLY < <(compgen -W \"${completions[*]}\" -- \"$cur\")\n";
funcDef += "}\n";
funcDef += blockEnd + "\n";
std::string completeLine = "complete -F " + funcName + " " + toolName + " # dropshell-autocomplete:" + toolName;