LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   What does [if test "/usr/local/bin/php" = '@'php_bin'@'; then] test for (https://www.linuxquestions.org/questions/programming-9/what-does-%5Bif-test-usr-local-bin-php-%3D-%40php_bin%40%3B-then%5D-test-for-765329/)

zhjim 10-29-2009 10:11 AM

What does [if test "/usr/local/bin/php" = '@'php_bin'@'; then] test for
 
Hi folks

I'm waiding through some php stuff and came upon the pear script. Within I found the mysteries line
Code:

if test "/usr/local/bin/php" = '@'php_bin'@'; then
and now wonder what the heck '@'php_bin'@' means.

For completion heres the complete pear script
Code:

#!/bin/sh

# first find which PHP binary to use
if test "x$PHP_PEAR_PHP_BIN" != "x"; then
  PHP="$PHP_PEAR_PHP_BIN"
else
  if test "/usr/local/bin/php" = '@'php_bin'@'; then
    PHP=php
  else
    PHP="/usr/local/bin/php"
  fi
fi

# then look for the right pear include dir
if test "x$PHP_PEAR_INSTALL_DIR" != "x"; then
  INCDIR=$PHP_PEAR_INSTALL_DIR
  INCARG="-d include_path=$PHP_PEAR_INSTALL_DIR"
else
  if test "/usr/local/lib/php" = '@'php_dir'@'; then
    INCDIR=`dirname $0`
    INCARG=""
  else
    INCDIR="/usr/local/lib/php"
    INCARG="-d include_path=/usr/local/lib/php"
  fi
fi

exec $PHP -C -q $INCARG -d output_buffering=1 -d variables_order=EGPCS -d open_basedir="" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" $INCDIR/pearcmd.php "$@"


ta0kira 10-31-2009 12:04 AM

Probably a substitution, although I don't use PHP or pear. What happens if you remove @? What happens if you echo '@'php_bin'@'?
Kevin Barry

DougRoyal 10-31-2009 01:52 AM

This isn't exactly a pear script; it's a shell script pear uses to get data about how you have PHP set up on your system.

The @ symbol has no relevance to PHP in this context (in a PHP script, the @ symbol suppresses errors, but this isn't a PHP script).

I don't use pear, but, based on what the rest of the script does, it looks like php_bin and php_dir _might_ be either commandline utilities or some kind of environmental variable installed with pear. If pear is set up on your system then php_bin would probably point to your system's PHP installation.

------
update
------
I just stopped by the #pear channel and they called them 'replacements' and told me to type:

pear config-show

which gives a listing of pear's configuration variables.

zhjim 11-02-2009 02:33 AM

I was a bit in a hurry writing this thread. So I just wrote pear script. What I meant was the pear bash script. ( Doesn't sound good either ;))

If I just echo '@'php_bin'@' before the if block it just prints
Code:

@php_bin@
but the trail with pear config-show seems good. If you grep for it you get the line
Code:

PHP CLI/CGI binary            php_bin          /usr/bin/php
One can also find the other '@'var_name'@' from the bash script within the output of pear config-show. So I concluded its some internal variable substition. Maybe when pear is called from within pear or the user has a config file on its own (also I doubt later cause no config file is parsed...)

Thanks to the both of you I'm all set and my nosiness is satisfied :D
Cheers Zhjim


All times are GMT -5. The time now is 05:35 PM.