Add qvm clean; make rebuild produce VM runner; default qvm run to shell

This commit is contained in:
Joshua Bell 2026-01-26 10:14:23 -06:00
parent e766c8466d
commit 601b4ab15e
7 changed files with 395 additions and 249 deletions

View file

@ -153,17 +153,18 @@ is_workspace_mounted() {
#
main() {
# Show usage if no arguments
if [[ $# -eq 0 ]]; then
show_usage
exit 1
fi
# Handle help flags
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
# Handle help flags first
if [[ $# -gt 0 && ( "$1" == "-h" || "$1" == "--help" ) ]]; then
show_usage
exit 0
fi
# If no command given, default to interactive zsh shell
local run_shell=false
if [[ $# -eq 0 ]]; then
run_shell=true
fi
# Get current workspace (absolute path)
local workspace_path
workspace_path="$(pwd)"
@ -268,25 +269,30 @@ main() {
# Add connection target
ssh_cmd+=(root@localhost)
# Build remote command: cd to workspace and execute user's command
# Quote each argument properly to handle spaces and special chars
local remote_cmd="cd '$guest_path' && "
# Build remote command: cd to workspace and execute user's command (or shell)
local remote_cmd="cd '$guest_path'"
# Append user's command with proper quoting
local first_arg=1
for arg in "$@"; do
if [[ $first_arg -eq 1 ]]; then
remote_cmd+="$arg"
first_arg=0
else
# Quote arguments that contain spaces or special characters
if [[ "$arg" =~ [[:space:]] ]]; then
remote_cmd+=" '$arg'"
if [[ "$run_shell" == "true" ]]; then
# No command - start interactive zsh shell
remote_cmd+=" && exec zsh"
else
# Append user's command with proper quoting
remote_cmd+=" && "
local first_arg=1
for arg in "$@"; do
if [[ $first_arg -eq 1 ]]; then
remote_cmd+="$arg"
first_arg=0
else
remote_cmd+=" $arg"
# Quote arguments that contain spaces or special characters
if [[ "$arg" =~ [[:space:]] ]]; then
remote_cmd+=" '$arg'"
else
remote_cmd+=" $arg"
fi
fi
fi
done
done
fi
# Add the remote command as final SSH argument
ssh_cmd+=("$remote_cmd")