1
0
Fork 0
mirror of synced 2024-07-01 04:20:55 +12:00

add note about issue 1191 and shell requoting or special chars

This commit is contained in:
Nick Sweeting 2024-01-18 20:33:52 -08:00
parent 216e0b7ec2
commit 820c15298c

View file

@ -180,9 +180,11 @@ if [[ "$1" == /* || "$1" == "bash" || "$1" == "sh" || "$1" == "echo" || "$1" ==
# "docker run archivebox /bin/bash -c '...'"
# "docker run archivebox cat /VERSION.txt"
exec gosu "$PUID" /bin/bash -c "exec $(printf ' %q' "$@")"
# WARNING: make sure to test extensively if you change this line, there are many edge-cases with nested quotes, special character, etc.
# printf requotes shell parameters properly https://stackoverflow.com/a/39463371/2156113
# gosu spawns an ephemeral bash process owned by archivebox user (bash wrapper is needed to load env vars, PATH, and setup terminal TTY)
# outermost exec hands over current process ID to inner bash process, inner exec hands over inner bash PID to user's command
# - https://github.com/ArchiveBox/ArchiveBox/issues/1191
else
# handle "docker run archivebox add some subcommand --with=args abc" by calling archivebox to run as args as CLI subcommand
# e.g. "docker run archivebox help"