Remove sudo prefix from command if detected
This commit is contained in:
parent
a77777987d
commit
cbd4e2bcac
2 changed files with 14 additions and 0 deletions
|
@ -61,6 +61,11 @@ function _is_auto_notify_ignored() {
|
|||
# Remove leading whitespace
|
||||
target_command="$(echo "$target_command" | sed -e 's/^ *//')"
|
||||
|
||||
# Remove sudo prefix from command if detected
|
||||
if [[ "$target_command" == "sudo "* ]]; then
|
||||
target_command="${target_command/sudo /}"
|
||||
fi
|
||||
|
||||
# If AUTO_NOTIFY_WHITELIST is defined, then auto-notify will ignore
|
||||
# any item not defined in the white list
|
||||
# Otherwise - the alternative (default) approach is used where the
|
||||
|
|
|
@ -51,3 +51,12 @@
|
|||
assert $state equals 0
|
||||
assert "$output" same_as "no"
|
||||
}
|
||||
|
||||
@test 'is_auto_notify_ignored - AUTO_NOTIFY_WHITELIST allowed with sudo' {
|
||||
AUTO_NOTIFY_WHITELIST="foobar"
|
||||
|
||||
run _is_auto_notify_ignored "sudo foobar baz"
|
||||
|
||||
assert $state equals 0
|
||||
assert "$output" same_as "no"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue