Browse Source

bash.custom: do not hang if command returns stderr

master
Pekka Helenius 5 years ago
committed by GitHub
parent
commit
c39da95aec
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 17 deletions
  1. +13
    -17
      bash.custom

+ 13
- 17
bash.custom View File

@ -593,8 +593,6 @@ sudocheck() {
#
# NOTE: This does not work for nano or cd commands
#
trap 'sudoperms' ERR
function sudoperms() {
# Previous command (ERR) always returns value 1 which is not
@ -603,7 +601,6 @@ function sudoperms() {
unset PROMPT_COMMAND
local CMD="${BASH_COMMAND}"
local i=0
# WORKAROUND
# rm command has an interactive prompt where
@ -616,23 +613,22 @@ function sudoperms() {
CMD=$(printf "${CMD}" | sed -E 's/^rm/rm -f/')
fi
while [[ $i < 1 ]]; do
if [[ $(${CMD} 2>&1 > /dev/null | grep -E "${ERROR_MSGS}") ]]; then
printf "${INFO_MSG}\n"
sudocheck
if [[ $? -eq 0 ]]; then
INFO_SEP
if [[ $(${CMD} 2>&>1 > /dev/null | grep -E "${ERROR_MSGS}") ]]; then
printf "${INFO_MSG}\n"
sudocheck
if [[ $? -eq 0 ]]; then
INFO_SEP
# Execute the failed command with sudo and get its return code
sudo bash -c "${CMD}" && RETCODE
fi
# Execute the failed command with sudo and get its return code
sudo bash -c "${CMD}" && RETCODE
fi
let i++
done
fi
checkdone=
}
if [[ -z checkdone ]]; then
trap 'sudoperms' ERR
fi
#######################################
# If nano doesn't have correct permissions, use sudo


Loading…
Cancel
Save