Fallback for existing sandbox and name collision
This commit is contained in:
parent
962002aec1
commit
1cc8dddc30
2 changed files with 46 additions and 4 deletions
22
install.sh
22
install.sh
|
|
@ -22,7 +22,27 @@ mkdir -p "$BIN_DIR"
|
|||
|
||||
cat > "$SHIM" <<'EOF'
|
||||
#!/bin/sh
|
||||
exec sbx run -t localhost/opencode-v2:local "$@" opencode
|
||||
# sbx run accepts -t/--template only at sandbox creation time; re-running
|
||||
# against an existing sandbox with a template fails. So pass the template
|
||||
# only when the named sandbox doesn't exist yet.
|
||||
TEMPLATE=localhost/opencode-v2:local
|
||||
|
||||
# Extract --name VALUE / --name=VALUE from the arguments, if given.
|
||||
name=
|
||||
prev=
|
||||
for arg in "$@"; do
|
||||
[ "$prev" = --name ] && name=$arg
|
||||
case "$arg" in
|
||||
--name=*) name=${arg#--name=} ;;
|
||||
esac
|
||||
prev=$arg
|
||||
done
|
||||
|
||||
if [ -n "$name" ] && sbx ls -q 2>/dev/null | grep -Fxq -- "$name"; then
|
||||
exec sbx run "$@" opencode
|
||||
fi
|
||||
|
||||
exec sbx run -t "$TEMPLATE" "$@" opencode
|
||||
EOF
|
||||
chmod +x "$SHIM"
|
||||
echo "==> Installed shim: $SHIM"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue