Fix PSQL Console plugin for OS X

Поиск
Список
Период
Сортировка
Искать

Fix PSQL Console plugin for OS X

От:
Nicola Vitacolonna <nvitacolonna@gmail.com>
Дата:
Вложения:
The PSQL Console command has been broken for a long time on OS X. Could you please fix it?

This is how the command should look like:

Command=/usr/bin/osascript -e 'ignoring application responses' -e 'tell application "Terminal"' -e 'activate' -e 'do script ""' -e 'do script "\'$$PGBINDIR/psql\' --host \'$$HOSTNAME\' --port $$PORT --username \'$$USERNAME\' \'$$DATABASE\' && exit || sleep 5 && exit" in window 1' -e 'end tell' -e 'end ignoring'

For humans:

ignoring application responses
	tell application "Terminal"
		do script "" -- open a new Terminal window
		do script "$$PGBINDIR/psql --host '$$HOSTNAME' --port $$PORT --username '$$USERNAME' '$$DATABASE' && exit || sleep 5 && exit" in window 1
		activate
	end tell
end ignoring

The changes are as follows:

1) add `do script “”` to open a new Terminal window. This is necessary because in the current window there may be a running process.
2) Remove `with command` (not wrong, but redundant).
3) Add `in window 1`. This is essential, otherwise the command fails.
4) Move `activate` at the end. This change is not strictly necessary, it is just a matter personal preference.

Thanks,
Nicola

PS: Is there a way to contribute to the code directly (à la Github)?

Re: Fix PSQL Console plugin for OS X

От:
Dave Page <dpage@pgadmin.org>
Дата:
Hi

On Fri, Mar 18, 2016 at 9:44 PM, Nicola Vitacolonna
 wrote:
> The PSQL Console command has been broken for a long time on OS X. Could you please fix it?
>
> This is how the command should look like:
>
> Command=/usr/bin/osascript -e 'ignoring application responses' -e 'tell application "Terminal"' -e 'activate' -e 'do script ""' -e 'do script "\'$$PGBINDIR/psql\' --host \'$$HOSTNAME\' --port $$PORT --username \'$$USERNAME\' \'$$DATABASE\' && exit || sleep 5 && exit" in window 1' -e 'end tell' -e 'end ignoring'
>
> For humans:
>
> ignoring application responses
>         tell application "Terminal"
>                 do script "" -- open a new Terminal window
>                 do script "$$PGBINDIR/psql --host '$$HOSTNAME' --port $$PORT --username '$$USERNAME' '$$DATABASE' && exit || sleep 5 && exit" in window 1
>                 activate
>         end tell
> end ignoring
>
> The changes are as follows:
>
> 1) add `do script “”` to open a new Terminal window. This is necessary because in the current window there may be a running process.

I'm not sure why you need this. I don't - I always get a new window
when using the plugin.

> 2) Remove `with command` (not wrong, but redundant).
> 3) Add `in window 1`. This is essential, otherwise the command fails.

Similarly, that's never been an issue for me.

> 4) Move `activate` at the end. This change is not strictly necessary, it is just a matter personal preference.
>
> PS: Is there a way to contribute to the code directly (à la Github)?

Please send patches (created with 'git diff') against  the repo at
http://git.postgresql.org/gitweb/?p=pgadmin3.git;a=summary. We don't
use Github.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: Fix PSQL Console plugin for OS X

От:
Nicola <nvitacolonna@gmail.com>
Дата:
On 2016-03-21 14:33:27 +0000, Dave Page said:

> Hi
> 
> On Fri, Mar 18, 2016 at 9:44 PM, Nicola Vitacolonna
>  wrote:
>> The PSQL Console command has been broken for a long time on OS X. Could 
>> you please fix it?
>> 
>> This is how the command should look like:
>> 
>> Command=/usr/bin/osascript -e 'ignoring application responses' -e 'tell 
>> application "Terminal"' -e 'activate' -e 'do script ""' -e 'do script 
>> "\'$$PGBINDIR/psql\' --host \'$$HOSTNAME\' --port $$PORT --username 
>> \'$$USERNAME\' \'$$DATABASE\' && exit || sleep 5 && exit" in window 1' 
>> -e 'end tell' -e 'end ignoring'
>> 
>> For humans:
>> 
>> ignoring application responses
>> tell application "Terminal"
>> do script "" -- open a new Terminal window
>> do script "$$PGBINDIR/psql --host '$$HOSTNAME' --port $$PORT --username 
>> '$$USERNAME' '$$DATABASE' && exit || sleep 5 && exit" in window 1
>> activate
>> end tell
>> end ignoring
>> 
>> The changes are as follows:
>> 
>> 1) add `do script “”` to open a new Terminal window. This is necessary 
>> because in the current window there may be a running process.
> 
> I'm not sure why you need this. I don't - I always get a new window
> when using the plugin.
> 
>> 2) Remove `with command` (not wrong, but redundant).
>> 3) Add `in window 1`. This is essential, otherwise the command fails.
> 
> Similarly, that's never been an issue for me.

I have found that the bug depends on the name of some of my terminal 
profiles. To reproduce it, just add a [ to the name of some profile.

Specifically, I have a profile called 'Apple ][ PR#3' (not the 
default). This is what is logged to the Console when I run PSQL Console 
from pgAdmin3:

22/03/16 09:51:52,235 Terminal[982]: An exception was thrown during 
execution of an NSScriptCommand...
22/03/16 09:51:52,235 Terminal[982]: Can't do regex matching, reason: 
Can't open pattern U_REGEX_MISSING_CLOSE_BRACKET (string 
'/usr/local/bin/psql' --host '127.0.0.1' --port 5432 --username 
'nicola' 'test' && exit || sleep 5 && exit, pattern Apple ][ PR#3, case 
0, canon 0)

No idea why the name of a profile should break the script. Possibly a 
Terminal.app's bug.

Nicola

Re: Fix PSQL Console plugin for OS X

От:
Dave Page <dpage@pgadmin.org>
Дата:
Hi

On Tue, Mar 22, 2016 at 9:39 AM, Nicola  wrote:
> On 2016-03-21 14:33:27 +0000, Dave Page said:
>
>> Hi
>>
>> On Fri, Mar 18, 2016 at 9:44 PM, Nicola Vitacolonna
>>  wrote:
>>>
>>> The PSQL Console command has been broken for a long time on OS X. Could
>>> you please fix it?
>>>
>>> This is how the command should look like:
>>>
>>> Command=/usr/bin/osascript -e 'ignoring application responses' -e 'tell
>>> application "Terminal"' -e 'activate' -e 'do script ""' -e 'do script
>>> "\'$$PGBINDIR/psql\' --host \'$$HOSTNAME\' --port $$PORT --username
>>> \'$$USERNAME\' \'$$DATABASE\' && exit || sleep 5 && exit" in window 1' -e
>>> 'end tell' -e 'end ignoring'
>>>
>>> For humans:
>>>
>>> ignoring application responses
>>> tell application "Terminal"
>>> do script "" -- open a new Terminal window
>>> do script "$$PGBINDIR/psql --host '$$HOSTNAME' --port $$PORT --username
>>> '$$USERNAME' '$$DATABASE' && exit || sleep 5 && exit" in window 1
>>> activate
>>> end tell
>>> end ignoring
>>>
>>> The changes are as follows:
>>>
>>> 1) add `do script “”` to open a new Terminal window. This is necessary
>>> because in the current window there may be a running process.
>>
>>
>> I'm not sure why you need this. I don't - I always get a new window
>> when using the plugin.
>>
>>> 2) Remove `with command` (not wrong, but redundant).
>>> 3) Add `in window 1`. This is essential, otherwise the command fails.
>>
>>
>> Similarly, that's never been an issue for me.
>
>
> I have found that the bug depends on the name of some of my terminal
> profiles. To reproduce it, just add a [ to the name of some profile.
>
> Specifically, I have a profile called 'Apple ][ PR#3' (not the default).
> This is what is logged to the Console when I run PSQL Console from pgAdmin3:
>
> 22/03/16 09:51:52,235 Terminal[982]: An exception was thrown during
> execution of an NSScriptCommand...
> 22/03/16 09:51:52,235 Terminal[982]: Can't do regex matching, reason: Can't
> open pattern U_REGEX_MISSING_CLOSE_BRACKET (string '/usr/local/bin/psql'
> --host '127.0.0.1' --port 5432 --username 'nicola' 'test' && exit || sleep 5
> && exit, pattern Apple ][ PR#3, case 0, canon 0)
>
> No idea why the name of a profile should break the script. Possibly a
> Terminal.app's bug.

Urgh, yes that is broken. I've committed your changes - thanks!

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

FAQ