| 1 | #!/bin/bash |
| 2 | # Copyright 2020 Simon McVittie |
| 3 | # SPDX-License-Identifier: LGPL-2.1+ |
| 4 | |
| 5 | set -eux |
| 6 | set -o pipefail |
| 7 | |
| 8 | #export PX_DEBUG=1 |
| 9 | |
| 10 | reset () { |
| 11 | unset DESKTOP_SESSION |
| 12 | unset FTP_PROXY |
| 13 | unset GNOME_DESKTOP_SESSION_ID |
| 14 | unset GSETTINGS_BACKEND |
| 15 | unset HTTPS_PROXY |
| 16 | unset HTTP_PROXY |
| 17 | unset KDE_FULL_SESSION |
| 18 | unset NO_PROXY |
| 19 | unset ftp_proxy |
| 20 | unset http_proxy |
| 21 | unset https_proxy |
| 22 | unset no_proxy |
| 23 | } |
| 24 | |
| 25 | reset |
| 26 | |
| 27 | answer="$(echo http://example.com | http_proxy=http://proxy.example.net https_proxy=http://sslproxy.example.net proxy)" |
| 28 | test "${answer}" = http://proxy.example.net |
| 29 | |
| 30 | answer="$(http_proxy=http://proxy.example.net https_proxy=http://sslproxy.example.net proxy http://example.com)" |
| 31 | test "${answer}" = http://proxy.example.net |
| 32 | |
| 33 | answer="$(http_proxy=http://proxy.example.net https_proxy=http://sslproxy.example.net proxy https://example.com)" |
| 34 | test "${answer}" = http://sslproxy.example.net |
| 35 | |
| 36 | answer="$(http_proxy=http://proxy.example.net https_proxy=http://sslproxy.example.net ftp_proxy=http://ftpproxy.example.net:8000 proxy ftp://ftp.example.com)" |
| 37 | test "${answer}" = http://ftpproxy.example.net:8000 |
| 38 | |
| 39 | answer="$(http_proxy=http://proxy.example.net https_proxy=http://sslproxy.example.net no_proxy=example.com proxy http://example.com)" |
| 40 | test "${answer}" = direct:// |