Files
swift-nio/swiftw
T

30 lines
595 B
Bash
Executable File

#!/bin/bash
set -eu
swift_binary=swift
declare -a extra_args
extra_args=()
if [[ ! -z "${SWIFT_EXEC-}" ]]; then
swift_binary="$(dirname "$SWIFT_EXEC")/swift"
elif [[ "$(uname -s)" == "Linux" ]]; then
swift_binary=$(which swift)
fi
if [[ $# -eq 0 ]]; then
verb=repl
if [[ "$(uname -s)" == "Linux" ]]; then
# to work around not being able to import Foundation in the REPL
extra_args+="-I$(dirname "$swift_binary")/../lib/swift/clang/include/"
fi
else
verb="$1"
shift
fi
"$swift_binary" "$verb" \
${extra_args[@]+"${extra_args[@]}"} \
"$@"