minor: ~ not resolved in psql

Started by Bas Scheffersover 22 years ago9 messagesbugs
Jump to latest
#1Bas Scheffers
bas@scheffers.net

============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name : Bas Scheffers
Your email address : bas@scheffers.net

System Configuration
---------------------
Architecture (example: Intel Pentium) : Athlon

Operating System (example: Linux 2.0.26 ELF) : Linux 2.4.22

PostgreSQL version (example: PostgreSQL-7.3.4): PostgreSQL-7.3.4

Compiler used (example: gcc 2.95.2) : RPM (Red Hat "Severn")

Please enter a FULL description of your problem:
------------------------------------------------
When opening a file in psql, ~ (the user's home dir) is resolved when
using tab completion to find the file, but when you hit enter and psql
actualy tries to open it, you get a file not found error.

Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------
N/A

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

#2Rod Taylor
rbt@rbt.ca
In reply to: Bas Scheffers (#1)
Re: minor: ~ not resolved in psql

Please enter a FULL description of your problem:
------------------------------------------------
When opening a file in psql, ~ (the user's home dir) is resolved when
using tab completion to find the file, but when you hit enter and psql
actualy tries to open it, you get a file not found error.

This is an issue in 7.4 as well.

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Bas Scheffers (#1)
Re: minor: ~ not resolved in psql

Bas Scheffers writes:

When opening a file in psql, ~ (the user's home dir) is resolved when
using tab completion to find the file, but when you hit enter and psql
actualy tries to open it, you get a file not found error.

This is not a bug. If there is not file named ~ then it can't be opened.

--
Peter Eisentraut peter_e@gmx.net

#4Bas Scheffers
bas@scheffers.net
In reply to: Peter Eisentraut (#3)
Re: minor: ~ not resolved in psql

Peter Eisentraut said:

This is not a bug. If there is not file named ~ then it can't be
opened.

I am not trying to open a file named ~, I am using it as part of a file
name, ie: ~/ewap/sql/ewap.sql. (where ~=/home/bas) This is perfectly valid
on any unix system and especialy since tab completion of \i supports it,
so should the function that does the actual opening of the file, I would
think...

Bas.

#5Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#3)
Re: minor: ~ not resolved in psql

Peter Eisentraut wrote:

Bas Scheffers writes:

When opening a file in psql, ~ (the user's home dir) is resolved when
using tab completion to find the file, but when you hit enter and psql
actualy tries to open it, you get a file not found error.

This is not a bug. If there is not file named ~ then it can't be opened.

If I am in psql and do:

\i ~/<tab>

I see all the files in home directory. If I then type in a file name:

test=> \i ~/server.log
~/server.log: No such file or directory

I get file not found. Sure looks like a bug to me.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#6Rod Taylor
rbt@rbt.ca
In reply to: Peter Eisentraut (#3)
Re: minor: ~ not resolved in psql

On Thu, 2003-10-30 at 13:13, Peter Eisentraut wrote:

Bas Scheffers writes:

When opening a file in psql, ~ (the user's home dir) is resolved when
using tab completion to find the file, but when you hit enter and psql
actualy tries to open it, you get a file not found error.

This is not a bug. If there is not file named ~ then it can't be opened.

If the file doesn't exist, then surely tab completion shouldn't pick it
up either.

\i ~/.b<tab><tab> <- picks up files

After finishing a name, hit enter -- the file could not be found.

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#5)
Re: minor: ~ not resolved in psql

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Peter Eisentraut wrote:

Bas Scheffers writes:

When opening a file in psql, ~ (the user's home dir) is resolved when
using tab completion to find the file, but when you hit enter and psql
actualy tries to open it, you get a file not found error.

This is not a bug. If there is not file named ~ then it can't be opened.

Sure looks like a bug to me.

I think so too. If tab completion can find the file then we ought to be
willing to open it. Changing tab completion to not find the file would
be okay too, or at least consistent. It's the inconsistency that leads
me to call it a bug.

regards, tom lane

#8Francisco Olarte
folarte@peoplecall.com
In reply to: Bas Scheffers (#4)
Re: minor: ~ not resolved in psql

On Thursday 30 October 2003 19:18, Bas Scheffers wrote:

This is not a bug. If there is not file named ~ then it can't be
opened.

I am not trying to open a file named ~, I am using it as part of a file
name, ie: ~/ewap/sql/ewap.sql. (where ~=/home/bas) This is perfectly valid
on any unix system and especialy since tab completion of \i supports it,
so should the function that does the actual opening of the file, I would
think...

It's not valid in a unix system. It's an expansion performed by most shells.
In my system (Linux, bash2):

[patxifijo:~] ls ~/2do.txt
/home/folarte/2do.txt
[patxifijo:~] ls '~/2do.txt'
ls: ~/2do.txt: No such file or directory

In fact it works with all programs:

[patxifijo:~] echo ~/2do.txt
/home/folarte/2do.txt
[patxifijo:~] echo '~/2do.txt'
~/2do.txt

F.O.S.

#9Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#7)
Re: minor: ~ not resolved in psql

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Peter Eisentraut wrote:

Bas Scheffers writes:

When opening a file in psql, ~ (the user's home dir) is resolved when
using tab completion to find the file, but when you hit enter and psql
actualy tries to open it, you get a file not found error.

This is not a bug. If there is not file named ~ then it can't be opened.

Sure looks like a bug to me.

I think so too. If tab completion can find the file then we ought to be
willing to open it. Changing tab completion to not find the file would
be okay too, or at least consistent. It's the inconsistency that leads
me to call it a bug.

Added to TODO:

* Have psql '\i ~/<tab><tab>' actually load files it displays
from home dir

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073