File: set-env.sh

package info (click to toggle)
rakudo 2024.09-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,508 kB
  • sloc: perl: 4,815; ansic: 2,724; java: 2,622; javascript: 590; makefile: 434; sh: 370; cpp: 152
file content (110 lines) | stat: -rwxr-xr-x 3,571 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/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 $(dirname "$EXEC"))

while [ $# -gt 0 ]; do
    case $1 in
        "--fish")
            FISH=true
            ;;
        "--quiet")
            QUIET=true
            ;;
    esac
    shift
done

my_echo() {
    if [ "$QUIET" != true ]; then
        echo "$1"
    fi
}

my_echo "echo '                           Adding Rakudo to PATH';"
my_echo "echo '                          =======================';"
my_echo "echo '';"

NEW_PATH=$PATH
RAKUDO_PATH0="$DIR/bin"
RAKUDO_PATH1="$DIR/share/perl6/site/bin"
STUFF_DONE=false
for RPATH in $RAKUDO_PATH1 $RAKUDO_PATH0 ; do
    if echo "$NEW_PATH" | grep -vEq "(^|:)$RPATH($|:)" ; then
        NEW_PATH="$RPATH:$NEW_PATH"
        STUFF_DONE=true
    fi
done

if $STUFF_DONE ; then
    if [ "$FISH" = true ]; then
        NEW_PATH=$(echo "$NEW_PATH" | sed "s/:/ /g")
        echo "set -x PATH $NEW_PATH;"
    else
        echo "export PATH='$NEW_PATH';"
    fi
    my_echo "echo 'Paths successfully added.';"
else
    my_echo "echo 'Paths already set. Nothing to do.';"
fi

my_echo "echo '';
echo '================================================================================';
echo ' =========                                                             __   __';
echo '  ||_|_||                =============================                (  \,/  )';
echo '  || # ||                 Welcome to the Raku Console                  \_ O _/';
echo '  || # ||                =============================                 (_/ \_)';
echo '';
echo 'This console has all the tools available you need to get started using Raku.';
echo '';
echo 'Rakudo provides an interactive command line interpreter (a so called Read Eval';
echo 'Print Loop, REPL for short) you can use to quickly try out pieces of Raku code.';
echo 'Start it by typing:';
echo '';
echo '    raku';
echo '';
echo 'If you already have a Raku program in a file, you can run it by typing:';
echo '';
echo '    raku path/to/my/program.raku';
echo '';
echo 'To install additional modules you can use the Zef module manager:';
echo '';
echo '    zef install Some::Module';
echo '';
echo 'https://rakudo.org/           - The home of this implementation of Raku.';
echo 'https://raku.land/            - Go here to browse for Raku modules.';
echo 'https://docs.raku.org/        - The Raku documentation.';
echo 'https://web.libera.chat/#raku - The Raku user chat. Talk to us!';
echo '';
echo '                              Happy hacking!';
echo '';
echo '================================================================================';
echo '';
"