Re: Probable recursion in particular alias

2019-01-09 Thread Ante Perić
Yes, certainly. I've also minimized the .bashrc and .bash_profile in here to 
what will also reproduce. Running "foo" here will peg my CPU down.

zrak:~ synthmeat$ alias; declare -f
alias foo=' echo "bar"  '
shell_session_delete_expired () 
{ 
if ( [ ! -e "$SHELL_SESSION_TIMESTAMP_FILE" ] || [ -z "$(/usr/bin/find 
"$SHELL_SESSION_TIMESTAMP_FILE" -mtime -1d)" ] ); then
local expiration_lock_file="$SHELL_SESSION_DIR/_expiration_lockfile";
if /usr/bin/shlock -f "$expiration_lock_file" -p $$; then
echo -n 'Deleting expired sessions...';
local delete_count=$(/usr/bin/find "$SHELL_SESSION_DIR" -type f 
-mtime +2w -print -delete | /usr/bin/wc -l);
[ "$delete_count" -gt 0 ] && echo $delete_count' completed.' || 
echo 'none found.';
( umask 077;
/usr/bin/touch "$SHELL_SESSION_TIMESTAMP_FILE" );
/bin/rm "$expiration_lock_file";
fi;
fi
}
shell_session_history_allowed () 
{ 
if [ -n "$HISTFILE" ]; then
local allowed=0;
if shopt -q histappend || [ -n "$HISTTIMEFORMAT" ]; then
allowed=${SHELL_SESSION_HISTORY:-0};
else
allowed=${SHELL_SESSION_HISTORY:=1};
fi;
if [ $allowed -eq 1 ]; then
return 0;
fi;
fi;
return 1
}
shell_session_history_check () 
{ 
if [ ${SHELL_SESSION_DID_HISTORY_CHECK:-0} -eq 0 ]; then
SHELL_SESSION_DID_HISTORY_CHECK=1;
if shell_session_history_allowed; then
shell_session_history_enable;
fi;
if [ "$PROMPT_COMMAND" = "shell_session_history_check" ]; then
unset PROMPT_COMMAND;
else
if [[ $PROMPT_COMMAND =~ (.*)(; *shell_session_history_check *| 
*shell_session_history_check *; *)(.*) ]]; then
PROMPT_COMMAND="${BASH_REMATCH[1]}${BASH_REMATCH[3]}";
fi;
fi;
fi
}
shell_session_history_enable () 
{ 
( umask 077;
/usr/bin/touch "$SHELL_SESSION_HISTFILE_NEW" );
HISTFILE="$SHELL_SESSION_HISTFILE_NEW";
SHELL_SESSION_HISTORY=1
}
shell_session_save () 
{ 
if [ -n "$SHELL_SESSION_FILE" ]; then
echo -n 'Saving session...';
( umask 077;
echo 'echo Restored session: "$(/bin/date -r '$(/bin/date +%s)')"' >| 
"$SHELL_SESSION_FILE" );
declare -F shell_session_save_user_state > /dev/null && 
shell_session_save_user_state;
shell_session_history_allowed && shell_session_save_history;
echo 'completed.';
fi
}
shell_session_save_history () 
{ 
shell_session_history_enable;
history -a;
if [ -f "$SHELL_SESSION_HISTFILE_SHARED" ] && [ ! -s 
"$SHELL_SESSION_HISTFILE" ]; then
echo -ne '\n...copying shared history...';
( umask 077;
/bin/cp "$SHELL_SESSION_HISTFILE_SHARED" "$SHELL_SESSION_HISTFILE" );
fi;
echo -ne '\n...saving history...';
( umask 077;
/bin/cat "$SHELL_SESSION_HISTFILE_NEW" >> "$SHELL_SESSION_HISTFILE_SHARED" 
);
( umask 077;
/bin/cat "$SHELL_SESSION_HISTFILE_NEW" >> "$SHELL_SESSION_HISTFILE" );
: >| "$SHELL_SESSION_HISTFILE_NEW";
if [ -n "$HISTFILESIZE" ]; then
echo -n 'truncating history files...';
HISTFILE="$SHELL_SESSION_HISTFILE_SHARED";
HISTFILESIZE="$HISTFILESIZE";
HISTFILE="$SHELL_SESSION_HISTFILE";
HISTFILESIZE="$size";
HISTFILE="$SHELL_SESSION_HISTFILE_NEW";
fi;
echo -ne '\n...'
}
shell_session_update () 
{ 
shell_session_save && shell_session_delete_expired
}
update_terminal_cwd () 
{ 
local url_path='';
{ 
local i ch hexch LC_CTYPE=C LC_ALL=;
for ((i = 0; i < ${#PWD}; ++i))
do
ch="${PWD:i:1}";
if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then
url_path+="$ch";
else
printf -v hexch "%02X" "'$ch";
url_path+="%${hexch: -2:2}";
fi;
done
};
printf '\e]7;%s\a' "file://$HOSTNAME$url_path"
}
zrak:~ synthmeat$ bash --version
GNU bash, version 5.0.0(1)-release (x86_64-apple-darwin18.2.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted b

Probable recursion in particular alias

2019-01-09 Thread Ante Perić
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: darwin18.2.0
Compiler: clang
Compilation CFLAGS: -DSSH_SOURCE_BASHRC -Wno-parentheses -Wno-format-security
uname output: Darwin zrak 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 
20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64
Machine Type: x86_64-apple-darwin18.2.0

Bash Version: 5.0
Patch Level: 0
Release Status: release

Description:
Having an alias of type:
alias bug="\
   echo \"no output, 100% cpu\" \
  "
in .bashrc will give no output, will not complete, and it will peg the CPU to 
100%.

Repeat-By:
Just run the alias as specified in Description section.