| 1 | #!/bin/sh |
| 2 | |
| 3 | # SPDX-FileCopyrightText: Copyright The Lima Authors |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | set -eu |
| 7 | |
| 8 | # Environment Variables |
| 9 | # LIMA_INSTANCE: Specifies the name of the Lima instance to use. Default is "default". |
| 10 | # LIMA_SHELL: Specifies the shell interpreter to use inside the Lima instance. Default is the user's shell configured inside the instance. |
| 11 | # LIMA_WORKDIR: Specifies the initial working directory inside the Lima instance. Default is the current directory from the host. |
| 12 | # LIMACTL: Specifies the path to the limactl binary. Default is "limactl" in $PATH. |
| 13 | |
| 14 | : "${LIMA_INSTANCE:=default}" |
| 15 | : "${LIMA_SHELL:=}" |
| 16 | : "${LIMA_WORKDIR:=}" |
| 17 | : "${LIMACTL:=limactl}" |
| 18 | |
| 19 | if [ "$#" -eq 1 ]; then |
| 20 | if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then |
| 21 | base="$(basename "$0")" |
| 22 | echo "Usage: ${base} [COMMAND...]" |
| 23 | echo |
| 24 | echo "${base} is an alias for \"${LIMACTL} shell ${LIMA_INSTANCE}\"." |
| 25 | echo "The instance name (\"${LIMA_INSTANCE}\") can be changed by specifying \$LIMA_INSTANCE." |
| 26 | echo |
| 27 | echo "The shell and initial workdir inside the instance can be specified via \$LIMA_SHELL" |
| 28 | echo "and \$LIMA_WORKDIR." |
| 29 | echo |
| 30 | echo "See \`${LIMACTL} shell --help\` for further information." |
| 31 | exit 0 |
| 32 | elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then |
| 33 | exec "$LIMACTL" "$@" |
| 34 | fi |
| 35 | fi |
| 36 | |
| 37 | set - --instance "$LIMA_INSTANCE" "$@" |
| 38 | if [ -n "${LIMA_SHELL}" ]; then |
| 39 | set - --shell "$LIMA_SHELL" "$@" |
| 40 | fi |
| 41 | if [ -n "${LIMA_WORKDIR}" ]; then |
| 42 | set - --workdir "$LIMA_WORKDIR" "$@" |
| 43 | fi |
| 44 | # Avoid converting paths with MSYS2 |
| 45 | MSYS2_ARG_CONV_EXCL="*" |
| 46 | export MSYS2_ARG_CONV_EXCL |
| 47 | exec "$LIMACTL" shell "$@" |