Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-15 Thread Niklas Keller
Hey all,

please remember that you can also use php -r to quickly evaluate
expressions, e.g. generating a random password:

php -r 'var_dump(bin2hex(random_bytes(16)));'

I'm in favor of removal without readline.

Best,
Niklas

Rowan Tommins  schrieb am Mi., 12. Mai 2021, 22:46:

> On 12/05/2021 17:21, Levi Morrison via internals wrote:
> >  The interactive shell requires libedit or readline support, which
> > this build does not have.
> >  Run php without -a to get an interactive mode instead.
>
>
> Unless I'm missing something, the default CLI mode (php without -a) is
> "interactive PHP" only if you consider "cat > foo.txt" to be an
> "interactive editor". You can type a complete script (remembering to
> start with " "end of file") and it will execute it, then exit.
>
> I too have been stung by accidentally triggering this mode without
> readline enabled, and would be happy to see Nikita's patch merged.
>
> Regards,
>
> --
> Rowan Tommins
> [IMSoP]
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>


Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Rowan Tommins

On 12/05/2021 17:21, Levi Morrison via internals wrote:

 The interactive shell requires libedit or readline support, which
this build does not have.
 Run php without -a to get an interactive mode instead.



Unless I'm missing something, the default CLI mode (php without -a) is 
"interactive PHP" only if you consider "cat > foo.txt" to be an 
"interactive editor". You can type a complete script (remembering to 
start with ""end of file") and it will execute it, then exit.


I too have been stung by accidentally triggering this mode without 
readline enabled, and would be happy to see Nikita's patch merged.


Regards,

--
Rowan Tommins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Levi Morrison via internals
On Wed, May 12, 2021 at 10:13 AM David Gebler  wrote:
>
> On Wed, 12 May 2021, 09:13 Nikita Popov,  wrote:
>
> >
> > I think we would be better off disabling -a completely if readline is not
> > available, and exit with a helpful error message. I've opened
> > https://github.com/php/php-src/pull/6976 to that effect. Does that sound
> > reasonable?
> >
> > Regards,
> > Nikita
> >
>
> +1 for this, the shell is very useful but "interactive mode", the evidence
> is clear has a tendency to confuse people.
> To invert the question, would anyone have a good justification to NOT
> remove interactive mode?

I've never once ran `php -a` and wanted the behavior that comes if you
don't have readline or libedit available. As has been mentioned, if
you want that behavior run `php` without -a. There's no loss of
functionality here, methinks. As long as `php -a` gives a sensible
message if it wasn't built with readline or libedit that says such:

The interactive shell requires libedit or readline support, which
this build does not have.
Run php without -a to get an interactive mode instead.

Or something.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread David Gebler
On Wed, 12 May 2021, 09:13 Nikita Popov,  wrote:

>
> I think we would be better off disabling -a completely if readline is not
> available, and exit with a helpful error message. I've opened
> https://github.com/php/php-src/pull/6976 to that effect. Does that sound
> reasonable?
>
> Regards,
> Nikita
>

+1 for this, the shell is very useful but "interactive mode", the evidence
is clear has a tendency to confuse people.
To invert the question, would anyone have a good justification to NOT
remove interactive mode?

>


Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Aaron Piotrowski


> On May 12, 2021, at 3:12 AM, Nikita Popov  wrote:
> 
> Hi internals,
> 
> If the readline extension is enabled, PHP provides an interactive shell
> under -a. If it is not enabled, it falls back to an "interactive mode"
> (yes, the difference between "interactive shell" and "interactive mode" is
> important here). The interactive mode is simply an stdin input, which needs
> to be terminated using Ctrl+D. You can only run one script that way.
> 
> I think the current behavior is quite confusing, because it's really not
> obvious that you ended up in this fallback mode (you need to know the
> difference between "shell" and "mode" in the output) and most people
> wouldn't know what to do with it. The latest instance of this is
> https://bugs.php.net/bug.php?id=81033.
> 
> I think we would be better off disabling -a completely if readline is not
> available, and exit with a helpful error message. I've opened
> https://github.com/php/php-src/pull/6976 to that effect. Does that sound
> reasonable?
> 
> Regards,
> Nikita

This would have been helpful several years ago when I started compiling PHP 
myself and was confused why `php -a` broke. An error message would have saved 
me some time. So yes, please, merge it.

Aaron Piotrowski
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Bob Weinand
> Am 12.05.2021 um 10:12 schrieb Nikita Popov :
> 
> Hi internals,
> 
> If the readline extension is enabled, PHP provides an interactive shell
> under -a. If it is not enabled, it falls back to an "interactive mode"
> (yes, the difference between "interactive shell" and "interactive mode" is
> important here). The interactive mode is simply an stdin input, which needs
> to be terminated using Ctrl+D. You can only run one script that way.
> 
> I think the current behavior is quite confusing, because it's really not
> obvious that you ended up in this fallback mode (you need to know the
> difference between "shell" and "mode" in the output) and most people
> wouldn't know what to do with it. The latest instance of this is
> https://bugs.php.net/bug.php?id=81033.
> 
> I think we would be better off disabling -a completely if readline is not
> available, and exit with a helpful error message. I've opened
> https://github.com/php/php-src/pull/6976 to that effect. Does that sound
> reasonable?
> 
> Regards,
> Nikita

Hey Nikita,

yes, please merge that PR, I've been annoyed more than once that the php -a was 
not actually interactive despite a seemingly good message. (and as cmb noted, 
it's effectively identical to bare php without args.)

Bob
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Moritz Friedrich


> Am 12.05.2021 um 10:12 schrieb Nikita Popov :
> 
> Hi internals,
> 
> If the readline extension is enabled, PHP provides an interactive shell
> under -a. If it is not enabled, it falls back to an "interactive mode"
> (yes, the difference between "interactive shell" and "interactive mode" is
> important here). The interactive mode is simply an stdin input, which needs
> to be terminated using Ctrl+D. You can only run one script that way.
> 
> I think the current behavior is quite confusing, because it's really not
> obvious that you ended up in this fallback mode (you need to know the
> difference between "shell" and "mode" in the output) and most people
> wouldn't know what to do with it. The latest instance of this is
> https://bugs.php.net/bug.php?id=81033.
> 
> I think we would be better off disabling -a completely if readline is not
> available, and exit with a helpful error message. I've opened
> https://github.com/php/php-src/pull/6976 to that effect. Does that sound
> reasonable?
> 
> Regards,
> Nikita

Hi Nikita,
if I may ask, would it also be possible to have deadline as a mandatory 
dependency to always have the interactive shell available? Is there a good
reason to compile PHP without? Having a basic prompt available is really
handy at times — especially looking at Node.js with their ahead-completion
and general UX.
The same has been done for other PHP modules in the past, so I wonder if 
we could simply have readline as a guarantee.

Regards,
Moritz
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Nikita Popov
On Wed, May 12, 2021 at 11:44 AM Michelangelo van Dam 
wrote:

>
>
> > On 12 May 2021, at 11:39, Pierre  wrote:
> >
> > Le 12/05/2021 à 11:29, Joe Watkins a écrit :
> >> Morning Nikita,
> >>
> >> +1 on the change to cli.
> >>
> >> It can't really be a default extension right now because readline
> license
> >> is not compatible:
> >>
> >> https://github.com/php/php-src/pull/3823
> >>
> >> Even without the license problem, I'm not convinced of the value of
> adding
> >> the dependency: Because of this long standing strange behaviour, I don't
> >> really think the interactive shell is well used.
> >
> > Hello,
> >
> > I might be an exception, I don't know, but I do use it a lot (almost
> every day). I don't want to install psysh or anything like it, php -a is
> enough for what I do with it.
> >
> > Regards,
> >
> > Pierre
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: https://www.php.net/unsub.php
> >
>
> Hello,
>
> I’m using php -a daily on CLI to quickly try out hypothesis or evaluate
> expressions. No interest in using other tools.
>

Everyone, let's please keep discussion relating to the interactive shell
*with* readline out of this thread. Unless you are using the interactive
mode *without* readline, your usage will not be affected by the proposed
change.

If you want to discuss improvements to php -a *with* readline, then please
do so in a different thread.

Regards,
Nikita


Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Joe Watkins
Morning,

Still I think heavy use has to be the exception, especially heavy use where
readline is not available (because it's questionably useful).

Cheers
Joe

On Wed, 12 May 2021 at 11:39, Pierre  wrote:

> Le 12/05/2021 à 11:29, Joe Watkins a écrit :
> > Morning Nikita,
> >
> > +1 on the change to cli.
> >
> > It can't really be a default extension right now because readline license
> > is not compatible:
> >
> > https://github.com/php/php-src/pull/3823
> >
> > Even without the license problem, I'm not convinced of the value of
> adding
> > the dependency: Because of this long standing strange behaviour, I don't
> > really think the interactive shell is well used.
>
> Hello,
>
> I might be an exception, I don't know, but I do use it a lot (almost
> every day). I don't want to install psysh or anything like it, php -a is
> enough for what I do with it.
>
> Regards,
>
> Pierre
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>


Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Michelangelo van Dam



> On 12 May 2021, at 11:39, Pierre  wrote:
> 
> Le 12/05/2021 à 11:29, Joe Watkins a écrit :
>> Morning Nikita,
>> 
>> +1 on the change to cli.
>> 
>> It can't really be a default extension right now because readline license
>> is not compatible:
>> 
>> https://github.com/php/php-src/pull/3823
>> 
>> Even without the license problem, I'm not convinced of the value of adding
>> the dependency: Because of this long standing strange behaviour, I don't
>> really think the interactive shell is well used.
> 
> Hello,
> 
> I might be an exception, I don't know, but I do use it a lot (almost every 
> day). I don't want to install psysh or anything like it, php -a is enough for 
> what I do with it.
> 
> Regards,
> 
> Pierre
> 
> -- 
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
> 

Hello,

I’m using php -a daily on CLI to quickly try out hypothesis or evaluate 
expressions. No interest in using other tools.

Cheers,

Michelangelo
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Pierre

Le 12/05/2021 à 11:29, Joe Watkins a écrit :

Morning Nikita,

+1 on the change to cli.

It can't really be a default extension right now because readline license
is not compatible:

https://github.com/php/php-src/pull/3823

Even without the license problem, I'm not convinced of the value of adding
the dependency: Because of this long standing strange behaviour, I don't
really think the interactive shell is well used.


Hello,

I might be an exception, I don't know, but I do use it a lot (almost 
every day). I don't want to install psysh or anything like it, php -a is 
enough for what I do with it.


Regards,

Pierre

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php



Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Joe Watkins
Morning Nikita,

+1 on the change to cli.

It can't really be a default extension right now because readline license
is not compatible:

https://github.com/php/php-src/pull/3823

Even without the license problem, I'm not convinced of the value of adding
the dependency: Because of this long standing strange behaviour, I don't
really think the interactive shell is well used.

Cheers
Joe

On Wed, 12 May 2021 at 10:48, Nikita Popov  wrote:

> On Wed, May 12, 2021 at 10:37 AM Moritz Friedrich  wrote:
>
> >
> > > Am 12.05.2021 um 10:12 schrieb Nikita Popov :
> > >
> > > Hi internals,
> > >
> > > If the readline extension is enabled, PHP provides an interactive shell
> > > under -a. If it is not enabled, it falls back to an "interactive mode"
> > > (yes, the difference between "interactive shell" and "interactive mode"
> > is
> > > important here). The interactive mode is simply an stdin input, which
> > needs
> > > to be terminated using Ctrl+D. You can only run one script that way.
> > >
> > > I think the current behavior is quite confusing, because it's really
> not
> > > obvious that you ended up in this fallback mode (you need to know the
> > > difference between "shell" and "mode" in the output) and most people
> > > wouldn't know what to do with it. The latest instance of this is
> > > https://bugs.php.net/bug.php?id=81033.
> > >
> > > I think we would be better off disabling -a completely if readline is
> not
> > > available, and exit with a helpful error message. I've opened
> > > https://github.com/php/php-src/pull/6976 to that effect. Does that
> sound
> > > reasonable?
> > >
> > > Regards,
> > > Nikita
> >
> > Hi Nikita,
> > if I may ask, would it also be possible to have deadline as a mandatory
> > dependency to always have the interactive shell available? Is there a
> good
> > reason to compile PHP without? Having a basic prompt available is really
> > handy at times — especially looking at Node.js with their
> ahead-completion
> > and general UX.
> > The same has been done for other PHP modules in the past, so I wonder if
> > we could simply have readline as a guarantee.
>
>
> The readline extension has an external dependency on readline / libedit.
> Making it a required extension would also make this a required dependency.
> We avoid having dependencies for the minimal build. The only dependency we
> currently have is libpcre, and we vendor that one. I doubt we'll want to
> add a new vendored dependency, as they tend to be a major pain.
>
> I personally do not use the interactive shell (and I think most people who
> do use *an* interactive shell prefer psysh), so I don't think this can be
> reasonably considered a "required" feature.
>
> Regards,
> Nikita
>


Re: [PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Nikita Popov
On Wed, May 12, 2021 at 10:37 AM Moritz Friedrich  wrote:

>
> > Am 12.05.2021 um 10:12 schrieb Nikita Popov :
> >
> > Hi internals,
> >
> > If the readline extension is enabled, PHP provides an interactive shell
> > under -a. If it is not enabled, it falls back to an "interactive mode"
> > (yes, the difference between "interactive shell" and "interactive mode"
> is
> > important here). The interactive mode is simply an stdin input, which
> needs
> > to be terminated using Ctrl+D. You can only run one script that way.
> >
> > I think the current behavior is quite confusing, because it's really not
> > obvious that you ended up in this fallback mode (you need to know the
> > difference between "shell" and "mode" in the output) and most people
> > wouldn't know what to do with it. The latest instance of this is
> > https://bugs.php.net/bug.php?id=81033.
> >
> > I think we would be better off disabling -a completely if readline is not
> > available, and exit with a helpful error message. I've opened
> > https://github.com/php/php-src/pull/6976 to that effect. Does that sound
> > reasonable?
> >
> > Regards,
> > Nikita
>
> Hi Nikita,
> if I may ask, would it also be possible to have deadline as a mandatory
> dependency to always have the interactive shell available? Is there a good
> reason to compile PHP without? Having a basic prompt available is really
> handy at times — especially looking at Node.js with their ahead-completion
> and general UX.
> The same has been done for other PHP modules in the past, so I wonder if
> we could simply have readline as a guarantee.


The readline extension has an external dependency on readline / libedit.
Making it a required extension would also make this a required dependency.
We avoid having dependencies for the minimal build. The only dependency we
currently have is libpcre, and we vendor that one. I doubt we'll want to
add a new vendored dependency, as they tend to be a major pain.

I personally do not use the interactive shell (and I think most people who
do use *an* interactive shell prefer psysh), so I don't think this can be
reasonably considered a "required" feature.

Regards,
Nikita


[PHP-DEV] Disable interactive mode (-a) if readline not available

2021-05-12 Thread Nikita Popov
Hi internals,

If the readline extension is enabled, PHP provides an interactive shell
under -a. If it is not enabled, it falls back to an "interactive mode"
(yes, the difference between "interactive shell" and "interactive mode" is
important here). The interactive mode is simply an stdin input, which needs
to be terminated using Ctrl+D. You can only run one script that way.

I think the current behavior is quite confusing, because it's really not
obvious that you ended up in this fallback mode (you need to know the
difference between "shell" and "mode" in the output) and most people
wouldn't know what to do with it. The latest instance of this is
https://bugs.php.net/bug.php?id=81033.

I think we would be better off disabling -a completely if readline is not
available, and exit with a helpful error message. I've opened
https://github.com/php/php-src/pull/6976 to that effect. Does that sound
reasonable?

Regards,
Nikita