]> arthur.barton.de Git - bup.git/blob - cmd/python-cmd.sh
README: add 0.30.x to CI status table
[bup.git] / cmd / python-cmd.sh
1 #!/bin/sh
2
3 set -e
4
5 top="$(pwd)"
6 cmdpath="$0"
7 # loop because macos has no recursive resolution
8 while test -L "$cmdpath"; do
9     link="$(readlink "$cmdpath")"
10     cd "$(dirname "$cmdpath")"
11     cmdpath="$link"
12 done
13 script_home="$(cd "$(dirname "$cmdpath")" && pwd -P)"
14 cd "$top"
15
16 bup_libdir="$script_home/../lib"  # bup_libdir will be adjusted during install
17 export PYTHONPATH="$bup_libdir${PYTHONPATH:+:$PYTHONPATH}"
18
19 # Force python to use ISO-8859-1 (aka Latin 1), a single-byte
20 # encoding, to help avoid any manipulation of data from system APIs
21 # (paths, users, groups, command line arguments, etc.)
22
23 export PYTHONCOERCECLOCALE=0  # Perhaps not necessary, but shouldn't hurt
24
25 # We can't just export LC_CTYPE directly here because the locale might
26 # not exist outside python, and then bash (at least) may be cranky.
27
28 if [ "${LC_ALL+x}" ]; then
29     unset LC_ALL
30     exec env \
31          BUP_LC_ALL="$LC_ALL" \
32          LC_COLLATE="$LC_ALL" \
33          LC_MONETARY="$LC_ALL" \
34          LC_NUMERIC="$LC_ALL" \
35          LC_TIME="$LC_ALL" \
36          LC_MESSAGES="$LC_ALL" \
37          LC_CTYPE=ISO-8859-1 \
38          @bup_python@ "$@"
39 elif [ "${LC_CTYPE+x}" ]; then
40     exec env \
41          BUP_LC_CTYPE="$LC_CTYPE" \
42          LC_CTYPE=ISO-8859-1 \
43          @bup_python@ "$@"
44 else
45     exec env \
46          LC_CTYPE=ISO-8859-1 \
47          @bup_python@ "$@"
48 fi