Search contact with first arg and grep with second
This commit is contained in:
parent
ca0b6cfa67
commit
93b0becacf
25
kmail.sh
25
kmail.sh
@ -27,23 +27,34 @@ debug_message() {
|
||||
# ]]]
|
||||
|
||||
# Verify argument [[[
|
||||
debug_message "− Verify arguments : Script get ${#} argument(s)."
|
||||
case "$#" in
|
||||
0 )
|
||||
printf "${c_redb}%b${c_reset}\n" "Error : Expect at least one argument."
|
||||
exit 1
|
||||
;;
|
||||
1 )
|
||||
contact_info="${1}"
|
||||
debug_message "− Look for a contact with these informations:\n${contact_info}"
|
||||
{
|
||||
contact_line=$(khard email "${contact_info}" | sed -n 2p)
|
||||
} > /dev/null
|
||||
;;
|
||||
2 )
|
||||
contact_info="${1}"
|
||||
filter_pattern="${2}"
|
||||
debug_message "− Look for a contact with these informations:\n${contact_info}\nand filter results with:\n${filter_pattern}"
|
||||
{
|
||||
contact_line=$(khard email "${contact_info}" | grep -- "${filter_pattern}" | sed -n p)
|
||||
} > /dev/null
|
||||
;;
|
||||
* )
|
||||
debug_message "− Verify arguments : Script get ${#} arguments."
|
||||
contact_pattern="${*}"
|
||||
printf "${c_redb}%b${c_reset}\n" "Error : Expect between 1 and 2 arguments."
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
# ]]]
|
||||
|
||||
debug_message "− Look for a contact with these informations:\n${contact_pattern}"
|
||||
{
|
||||
contact_line=$(khard email "${contact_pattern}" | sed -n 2p)
|
||||
} > /dev/null
|
||||
|
||||
if [ -n "${contact_line}" ]; then
|
||||
debug_message "Matching contact:\n${contact_line}"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user