Skip to content

Commit

Permalink
added support for stdin, command-line args to R
Browse files Browse the repository at this point in the history
  • Loading branch information
dmalan committed Jan 31, 2024
1 parent 04f3705 commit 846269c
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions opt/cs50/bin/R
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#!/bin/bash

IMAGE="rocker/r-ver"

docker run \
--interactive \
--rm \
--tty \
--volume "$LOCAL_WORKSPACE_FOLDER":/mnt \
--workdir /mnt \
"$IMAGE"
IMAGE=rocker/r-ver

options=(
--interactive
--rm
--volume "$LOCAL_WORKSPACE_FOLDER":/mnt
--workdir /mnt
$IMAGE
R
"$@"
)

# If TTY
if [[ -t 0 ]]; then
options=(--tty "${options[@]}")
docker run "${options[@]}"

# If pipe
else
cat | docker run "${options[@]}"
fi

0 comments on commit 846269c

Please sign in to comment.