Curious PHP cli output in context of bash completion ?

Curious PHP cli output in context of bash completion ?

am 27.01.2010 22:46:59 von Alexandre Simon

Hello,

I'm pretty "sure" (in realty I do not understand a lot about the =
problem... :( ) this is a distribution or a version problem but maybe =
some PHP/bash expert here could have some idea and tell me what I could =
try to solve the problem described here :

http://ubuntuforums.org/showthread.php?p=3D8734334

Shortly : PHP cli seems to output something like newlines that bash can =
not intercept.

My initial goal is to complete a PHP script, using the PHP script =
itselfs as function for bash completion. Mechanism that works perfectly =
on some other platforms (with different PHP AND bash version ...) than =
Ubuntu 8.04 and 9.10 (PHP 5.2.4 and PHP 5.2.10 respectively). The =
interest : only one thing to code : the php script. Moreover : the PHP =
scripts knows "things" (DB connection, .. etc) that the bash script =
would have some difficulty to get.

Thank you a lot for any help.

--=20
Alex



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Curious PHP cli output in context of bash completion ?

am 27.01.2010 23:27:35 von Rene Veerman

Have you tried letting the php script output "\r\n" instead of just
"\n" as newline ?

On Wed, Jan 27, 2010 at 10:46 PM, Alexandre Simon wrot=
e:
> Hello,
>
> I'm pretty "sure" (in realty I do not understand a lot about the problem.=
... :( =A0) this is a distribution or a version problem but maybe some PHP/b=
ash expert here could have some idea and tell me what I could try to solve =
the problem described here :
>
> http://ubuntuforums.org/showthread.php?p=3D8734334
>
> Shortly : PHP cli seems to output something like newlines that bash can n=
ot intercept.
>
> My initial goal is to complete a PHP script, using the PHP script itselfs=
as function for bash completion. Mechanism that works perfectly on some ot=
her platforms (with different PHP AND bash version ...) than Ubuntu 8.04 an=
d 9.10 (PHP 5.2.4 and PHP 5.2.10 respectively). The interest : only one thi=
ng to code : the php script. Moreover : the PHP scripts knows "things" (DB =
connection, .. etc) that the bash script would have some difficulty to get.
>
> Thank you a lot for any help.
>
> --
> Alex
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Curious PHP cli output in context of bash completion ?

am 28.01.2010 00:42:16 von Ashley Sheridan

--=-fL0u6w61VAJsk/of2+YJ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Wed, 2010-01-27 at 23:27 +0100, Rene Veerman wrote:

> Have you tried letting the php script output "\r\n" instead of just
> "\n" as newline ?
>
> On Wed, Jan 27, 2010 at 10:46 PM, Alexandre Simon wrote:
> > Hello,
> >
> > I'm pretty "sure" (in realty I do not understand a lot about the problem... :( ) this is a distribution or a version problem but maybe some PHP/bash expert here could have some idea and tell me what I could try to solve the problem described here :
> >
> > http://ubuntuforums.org/showthread.php?p=8734334
> >
> > Shortly : PHP cli seems to output something like newlines that bash can not intercept.
> >
> > My initial goal is to complete a PHP script, using the PHP script itselfs as function for bash completion. Mechanism that works perfectly on some other platforms (with different PHP AND bash version ...) than Ubuntu 8.04 and 9.10 (PHP 5.2.4 and PHP 5.2.10 respectively). The interest : only one thing to code : the php script. Moreover : the PHP scripts knows "things" (DB connection, .. etc) that the bash script would have some difficulty to get.
> >
> > Thank you a lot for any help.
> >
> > --
> > Alex
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>


Also, MySQL has good command line tools and there are plenty of command
line interfaces to it you can use from Bash

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-fL0u6w61VAJsk/of2+YJ--

Re: Curious PHP cli output in context of bash completion ?

am 28.01.2010 08:26:16 von Alexandre Simon

The problem has nothing to do with "myscript.php" output.
The problem is in bash completion process wich involves only =
"echoscrip.[php|sh]". These scripts only have (to my comprehension) to =
output a single string, without newline and it is what they do.
The fact is, and I do not understand why because the output is exactly =
the same :=20
- using echoscript.sh to provide bash COMPREPLY variable value, bash =
completion works,
- using echoscript.php to do the same, bash completion does not work.

I tried to took for a runtime option (php.ini) but didn't found anything =
relevant.

PS : just because I had to do it, I tried to add newline and cariage =
return to all the scripts. The result is the same, unfortunately.

Le 27 janv. 2010 =E0 23:27, Rene Veerman a =E9crit :

> Have you tried letting the php script output "\r\n" instead of just
> "\n" as newline ?
>=20
> On Wed, Jan 27, 2010 at 10:46 PM, Alexandre Simon =
wrote:
>> Hello,
>>=20
>> I'm pretty "sure" (in realty I do not understand a lot about the =
problem... :( ) this is a distribution or a version problem but maybe =
some PHP/bash expert here could have some idea and tell me what I could =
try to solve the problem described here :
>>=20
>> http://ubuntuforums.org/showthread.php?p=3D8734334
>>=20
>> Shortly : PHP cli seems to output something like newlines that bash =
can not intercept.
>>=20
>> My initial goal is to complete a PHP script, using the PHP script =
itselfs as function for bash completion. Mechanism that works perfectly =
on some other platforms (with different PHP AND bash version ...) than =
Ubuntu 8.04 and 9.10 (PHP 5.2.4 and PHP 5.2.10 respectively). The =
interest : only one thing to code : the php script. Moreover : the PHP =
scripts knows "things" (DB connection, .. etc) that the bash script =
would have some difficulty to get.
>>=20
>> Thank you a lot for any help.
>>=20
>> --
>> Alex
>>=20
>>=20
>>=20
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>=20
>>=20

--=20
Alexandre Simon
http://alex.zybar.net




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Curious PHP cli output in context of bash completion ?

am 28.01.2010 08:27:15 von Alexandre Simon

--Apple-Mail-14-741110022
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=iso-8859-1


Le 28 janv. 2010 =E0 00:42, Ashley Sheridan a =E9crit :

> On Wed, 2010-01-27 at 23:27 +0100, Rene Veerman wrote:
>>=20
>>=20
>> > My initial goal is to complete a PHP script, using the PHP script =
itselfs as function for bash completion. Mechanism that works perfectly =
on some other platforms (with different PHP AND bash version ...) than =
Ubuntu 8.04 and 9.10 (PHP 5.2.4 and PHP 5.2.10 respectively). The =
interest : only one thing to code : the php script. Moreover : the PHP =
scripts knows "things" (DB connection, .. etc) that the bash script =
would have some difficulty to get.
>> >
>> > Thank you a lot for any help.
>> >
>> > --
>> > Alex
>> >
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>=20
>=20
> Also, MySQL has good command line tools and there are plenty of =
command line interfaces to it you can use from Bash
>=20
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

Yes, I know how to use MySQL binaries ;).
But it's not only about MySQL business : in my context, the PHP script =
has access to many business processes that only exists in PHP code. In =
this context (to my mind), it is quiet normal and simpler to get bash =
completion variables value from the PHP itself.

We could probably continue to discuss this design issue but the problem =
is that, in the context of bash completion process, echoscript.php and =
echoscript.sh that simply echo "a b c d" (exactly the same output), give =
different results and I can not understand why ... I searched for =
runtime options (php.ini) but didn't found anything relevant. I also =
searched about the "shebang" but with no result.

I just attached a modified version of completion.sh, the script to =
source in the current bash process to complete "myscript.php" (see =
http://ubuntuforums.org/showthread.php?p=3D8734334 for a complete =
description).
If you uncomment the lines that call echoscript.php and echoscript.sh, =
you can compare php.out and sh.out files and see they are identical =
(using "diff -b php.out sh.out" for instance). When echoscript.php is =
not called, the bash completion process works. When it is called the =
completion goes wrong, even if you do not use the output in the =
completion process (the modified version of completion.sh uses a =
"static" bash string "a b c d").

Can anyone understand what could happened ?

Thank you,


--=20
Alex




--Apple-Mail-14-741110022
Content-Type: multipart/mixed;
boundary=Apple-Mail-15-741110022


--Apple-Mail-15-741110022
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=iso-8859-1

-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
">

Le 28 janv. 2010 =E0 00:42, Ashley Sheridan a =E9crit =
:



On Wed, 2010-01-27 at 23:27 +0100, Rene Veerman wrote:


> My initial goal is to complete a PHP script, using the PHP script =
itselfs as function for bash completion. Mechanism that works perfectly =
on some other platforms (with different PHP AND bash version ...) than =
Ubuntu 8.04 and 9.10 (PHP 5.2.4 and PHP 5.2.10 respectively). The =
interest : only one thing to code : the php script. Moreover : the PHP =
scripts knows "things" (DB connection, .. etc) that the bash script =
would have some difficulty to get.
>
> Thank you a lot for any help.
>
> --
> Alex
>
>
>
> --
> PHP General Mailing List ( href=3D"http://www.php.net/">http://www.php.net/)
> To unsubscribe, visit: href=3D"http://www.php.net/unsub.php">http://www.php.net/unsub.php
>
>





Also, MySQL has good command line tools and there are plenty of command =
line interfaces to it you can use from Bash



style=3D"position: static; z-index: auto; ">




Thanks,

Ash

href=3D"http://www.ashleysheridan.co.uk">http://www.ashleysh eridan.co.uk a>





Yes, I know how to use MySQL binaries =
;).
But it's not only about MySQL business : in my context, =
the PHP script has access to many business processes that only exists in =
PHP code. In this context (to my mind), it is quiet normal and simpler =
to get bash completion variables value from the PHP =
itself.

We could probably continue to discuss =
this design issue but the problem is that, in the context of bash =
completion process, echoscript.php and echoscript.sh that simply echo "a =
b c d" (exactly the same output), give different results and I can not =
understand why ... I searched for runtime options (php.ini) but didn't =
found anything relevant. I also searched about the "shebang" but with no =
result.

I just attached a modified version of =
completion.sh, the script to source in the current bash process to =
complete "myscript.php" (see  href=3D"http://ubuntuforums.org/showthread.php?p=3D8734334"> http://ubuntuf=
orums.org/showthread.php?p=3D8734334
for a complete =
description).
If you uncomment the lines that call =
echoscript.php and echoscript.sh, you can compare php.out and sh.out =
files and see they are identical (using "diff -b php.out sh.out" for =
instance). When echoscript.php is not called, the bash completion =
process works. When it is called the completion goes wrong, even if you =
do not use the output in the completion process (the modified version of =
completion.sh uses a "static" bash string "a b c =
d").

Can anyone understand what could happened =
?

Thank =
you,

=

--Apple-Mail-15-741110022
Content-Disposition: attachment;
filename=completion.sh
Content-Type: application/octet-stream;
name="completion.sh"
Content-Transfer-Encoding: 7bit

#!/bin/bash

_completephp()
{
local cur cmds cmdOpts
cur="${COMP_WORDS[COMP_CWORD]}"

# lines to uncomment : when you uncomment the php version of "a b c d", it goes wrong (observed on Ubuntu 8.03 and 9.10 only). sh.out and php.out files are yet the same ...
# compgen -W "$(echoscript.sh)" -- "${cur}" > sh.out
# compgen -W "$(echoscript.php)" -- "${cur}" > php.out
COMPREPLY=( $( compgen -W "a b c d" -- "${cur}" ) )
return 0
}

complete -F _completephp -o "default" myscript.php

--Apple-Mail-15-741110022
Content-Transfer-Encoding: 7bit
Content-Type: text/html;
charset=us-ascii



-- 
Alex






--Apple-Mail-15-741110022--

--Apple-Mail-14-741110022--

Re: Curious PHP cli output in context of bash completion ?

am 28.01.2010 10:54:34 von Alexandre Simon

--001485f5b0d0991955047e36815e
Content-Type: text/plain; charset=ISO-8859-1

OK : I just recompiled, under Ubuntu 8.04, the same php version that the
distribution provides, used the same php.ini and it works... I didn't
applied the same patchs or even setted the same compilation options but for
me it's "clear" that it is a distribution problem.

I still do not know what exactly differs and makes the problem appear. Maybe
some PHP expert could orient me to the right direction (I'm not a Guru of
compilation, especiallly for PHP ...) ?

Thanks

2010/1/27 Alexandre Simon

> Hello,
>
> I'm pretty "sure" (in realty I do not understand a lot about the problem...
> :( ) this is a distribution or a version problem but maybe some PHP/bash
> expert here could have some idea and tell me what I could try to solve the
> problem described here :
>
> http://ubuntuforums.org/showthread.php?p=8734334
>
> Shortly : PHP cli seems to output something like newlines that bash can not
> intercept.
>
> My initial goal is to complete a PHP script, using the PHP script itselfs
> as function for bash completion. Mechanism that works perfectly on some
> other platforms (with different PHP AND bash version ...) than Ubuntu 8.04
> and 9.10 (PHP 5.2.4 and PHP 5.2.10 respectively). The interest : only one
> thing to code : the php script. Moreover : the PHP scripts knows "things"
> (DB connection, .. etc) that the bash script would have some difficulty to
> get.
>
> Thank you a lot for any help.
>
> --
> Alex
>
>
>


--
SIMON Alexandre

--001485f5b0d0991955047e36815e--