Skip to content

Instantly share code, notes, and snippets.

@nxadm
Created November 8, 2019 17:33
Show Gist options
  • Save nxadm/772b514ea812a8a85ee1ef8f9671dbbf to your computer and use it in GitHub Desktop.
Save nxadm/772b514ea812a8a85ee1ef8f9671dbbf to your computer and use it in GitHub Desktop.
$ docker run -ti -v ~/Downloads:/mnt centos:6 bash
[root@bc847ce8edfb /]# /mnt/rakudo-2019.07.1/bin/set-env.sh
[root@bc847ce8edfb /]# . /mnt/rakudo-2019.07.1/bin/set-env.sh
ERROR: 'bash' does not exist.
[root@bc847ce8edfb /]# cat /mnt/rakudo-2019.07.1/bin/set-env.sh
#!/bin/sh
# Sourced from https://stackoverflow.com/a/29835459/1975049
rreadlink() (
target=$1 fname= targetDir= CDPATH=
{ \unalias command; \unset -f command; } >/dev/null 2>&1
[ -n "$ZSH_VERSION" ] && options[POSIX_BUILTINS]=on
while :; do
[ -L "$target" ] || [ -e "$target" ] || { command printf '%s\n' "ERROR: '$target' does not exist." >&2; return 1; }
command cd "$(command dirname -- "$target")" || exit 1
fname=$(command basename -- "$target")
[ "$fname" = '/' ] && fname=''
if [ -L "$fname" ]; then
target=$(command ls -l "$fname")
target=${target#* -> }
continue
fi
break
done
targetDir=$(command pwd -P)
if [ "$fname" = '.' ]; then
command printf '%s\n' "${targetDir%/}"
elif [ "$fname" = '..' ]; then
command printf '%s\n' "$(command dirname -- "${targetDir}")"
else
command printf '%s\n' "${targetDir%/}/$fname"
fi
)
EXEC=$(rreadlink "$0")
DIR=$(dirname -- "$EXEC")
export PATH=$DIR/../bin:$DIR/../share/perl6/site/bin:$PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment