Skip to content

Commit

Permalink
dosh: add warning comment about shebang option
Browse files Browse the repository at this point in the history
  • Loading branch information
gportay committed Oct 6, 2024
1 parent cdb2f3f commit 3a4f48c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dosh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ then
exec "$0" "$@"
elif [ "$__" != "/bin/bash" ] && [ "$__" = "$2" ]
then
# Warning: Splitting the single shebang argument into many is not
# portable! Please consider using env(1) instead:
#
# #!/usr/bin/env -S dosh [ARGS...]
read -r -a args <<<"$1"
shift
exec <"$1"
Expand Down
10 changes: 10 additions & 0 deletions examples/shebang-env.dosh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env -S dosh --dockerfile Dockerfile.fedora
#
# Copyright (c) 2024 Gaël PORTAY
#
# SPDX-License-Identifier: MIT
#

whoami
echo "$USER" "$0" "$#" "$@"
cat /etc/os*release
10 changes: 10 additions & 0 deletions tests.bash
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,16 @@ else
fi
echo

run "Test shebang using env"
if examples/shebang-env.dosh | tee /dev/stderr | \
grep -q 'PRETTY_NAME="Fedora 25 (Twenty Five)'
then
ok
else
ko
fi
echo

run "Test options --detach and --exec"
if container="$(dosh --detach)" && \
dosh "$@" --exec "$container" -c "hostname" | tee /dev/stderr | \
Expand Down

0 comments on commit 3a4f48c

Please sign in to comment.