
sxmo_common.sh is in $PATH so we can let the shell handle finding it. Running a script with sh -x <scriptname> can be handy for debugging, but doesn't work with these because $0 doesn't get set to the full path to the script. Signed-off-by: Willow Barraco <contact@willowbarraco.fr>
36 lines
718 B
Bash
Executable File
36 lines
718 B
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# Copyright 2022 Sxmo Contributors
|
|
|
|
# shellcheck source=scripts/core/sxmo_common.sh
|
|
. sxmo_common.sh
|
|
|
|
returnvalid() {
|
|
printf %s "$1"
|
|
exit
|
|
}
|
|
|
|
if [ "$(printf "%b\n" "$1" | xargs -0 pnc find | xargs printf %s)" = "$1" ]; then
|
|
# a multiple formated phone number
|
|
returnvalid "$1"
|
|
fi
|
|
|
|
if pnc valid "$1"; then
|
|
returnvalid "$1"
|
|
fi
|
|
|
|
REFORMATTED="$(pnc find ${DEFAULT_COUNTRY:+-c "$DEFAULT_COUNTRY"} "$1")"
|
|
if pnc valid "$REFORMATTED"; then
|
|
printf %s "$REFORMATTED"
|
|
exit
|
|
fi
|
|
|
|
notify-send "\"$1\" is not a valid phone number"
|
|
|
|
PICKED="$(printf "Ok\nUse as it is\n" | sxmo_dmenu.sh -p "Invalid Number")"
|
|
if [ "$PICKED" = "Use as it is" ]; then
|
|
returnvalid "$1"
|
|
fi
|
|
|
|
exit 1
|