Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed SSH_CLIENT and minor changer per shellcheck #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions phpdebug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@
export IDE_ZEND_PORT=10137
export IDE_XDEBUG_PORT=9000
export IDE_KEY="PHPSTORM"
export IDE_SERVERNAME="$(hostname)"
export IDE_SERVERNAME=""

# @see https://github.com/koalaman/shellcheck/wiki/SC2155
IDE_SERVERNAME=$(hostname)

function _check_xdebug_installed()
{
if ! php -i | egrep -q "(xdebug|zend_debugger)"; then
echo "\e[0;31mWarning! XDebug or Zend Debugger extension not found\e[m"
if ! php -i | grep -E -q "(xdebug|zend_debugger)"; then
echo "Warning! XDebug or Zend Debugger extension not found"
fi
}

Expand All @@ -60,11 +63,11 @@ function _phpdebug()
local php_ide_config="serverName=${IDE_SERVERNAME}"

# try to autodetect IP if global variable IDE_IP not set
if [ -z ${IDE_IP+x} ]; then
if [ -z "$IDE_IP" ]; then
if [ -z "$SSH_CLIENT" ]; then
IDE_IP="127.0.0.1";
else
IDE_IP=$( echo $SSH_CLIENT | sed s/\ .*$// );
IDE_IP=$( echo "$SSH_CLIENT" | cut -d' ' -f1 );
fi
fi

Expand All @@ -79,7 +82,7 @@ function _phpdebug()
export XDEBUG_CONFIG="$xdebug_config"
export PHP_IDE_CONFIG="$php_ide_config"
else
PHP_IDE_CONFIG="$php_ide_config" XDEBUG_CONFIG="$xdebug_config" QUERY_STRING="$zend_debugger_config" php $*
PHP_IDE_CONFIG="$php_ide_config" XDEBUG_CONFIG="$xdebug_config" QUERY_STRING="$zend_debugger_config" php "$@"
fi
}
alias phpdebug="_phpdebug"
Expand Down