# shellcheck shell=bash # # Copyright (C) 2017 Canonical Ltd # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # etelpmoc is the reverse of complete: it de-serialises the tab completion # request into the appropriate environment variables expected by the tab # completion tools, performs whatever action is wanted, and serialises the # result. It accomplishes this by having functions override the builtin # completion commands. # # this always runs "inside", in the same environment you get when doing "snap # run --shell", and snap-exec is the one setting the first argument to the # completion script set in the snap. The rest of the arguments come through # from snap-run --command=complete _die() { echo "$*" >&2 exit 1 } if [[ "${BASH_SOURCE[0]}" != "$0" ]]; then _die "ERROR: this is meant to be run, not sourced." fi if [[ "${#@}" -lt 8 ]]; then _die "USAGE: $0