Skip to content

Commit

Permalink
fix: docker work directory
Browse files Browse the repository at this point in the history
  • Loading branch information
fentas committed Mar 28, 2024
1 parent 539d109 commit 794e18b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .bin/argsh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ argsh::main() {
local tty=""
[[ ! -t 1 ]] || tty="-it"
# shellcheck disable=SC2046
docker run --rm ${tty} $(docker::user) \
docker run --rm ${tty} $(docker::user) -w /workspace \
-e "BATS_LOAD" \
-e "ARGSH_SOURCE" \
-e "GIT_COMMIT_SHA=$(git rev-parse HEAD || :)" \
Expand Down
12 changes: 10 additions & 2 deletions libraries/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ docker::user() {
local user="${3:-"$(whoami)"}"
local home="${4:-"/workspace"}"
local shell="${5:-"/bin/sh"}"
local curr
curr="$(pwd)"
curr="${curr#"${PATH_BASE:-}"}"
if [[ "${curr}" == "$(pwd)" ]]; then
curr="${home}"
else
curr="${home}${curr}"
fi

echo "${user}:x:${uid}:${gid}::${home}:${shell}" > /tmp/docker_passwd
echo "${user}:x:${gid}:" > /tmp/docker_group
echo "-v /tmp/docker_passwd:/etc/passwd -v /tmp/docker_group:/etc/group"
echo "-u ${uid}:${gid}"

echo "-v ${PATH_BASE:-.}:${home}"
echo "-w ${home}"
echo "-v ${PATH_BASE:-"$(pwd)"}:${home}"
echo "-w ${curr}"
}
4 changes: 2 additions & 2 deletions libraries/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ argsh::shebang() {
return 1
} >&2
local tty=""
[[ ! -t 1 ]] || tty="-it"
! tty -s || tty="-it"
# shellcheck disable=SC2046
docker run --rm ${tty} $(docker::user) \
-e "BATS_LOAD" \
Expand All @@ -37,7 +37,7 @@ argsh::shebang() {
-e "GIT_VERSION=$(git describe --tags --dirty || :)" \
ghcr.io/arg-sh/argsh:latest "${@}"
return 0
} >&2
}
bash::version 4 3 0 || {
echo "This script requires bash 4.3.0 or later"
return 1
Expand Down

0 comments on commit 794e18b

Please sign in to comment.