public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug cli/15145] New: cd and $cwd do not handle symlink/../ correctly
@ 2013-02-13 17:44 jan.kratochvil at redhat dot com
  2013-02-13 22:58 ` [Bug cli/15145] " schwab@linux-m68k.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: jan.kratochvil at redhat dot com @ 2013-02-13 17:44 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15145

             Bug #: 15145
           Summary: cd and $cwd do not handle symlink/../ correctly
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: cli
        AssignedTo: unassigned@sourceware.org
        ReportedBy: jan.kratochvil@redhat.com
    Classification: Unclassified


cd_command tries to remove "name/../" from the path.
But that is incorrect if "name" is a symlink.

$ mkdir /tmp/{bar,baz,baz/xxx,baz/bar}
$ ln -s baz/xxx /tmp/foo
$ gdb -q -ex 'cd /tmp/foo/../bar' -ex 'path .' -ex r -ex q --args bash -c 'echo
$PATH'
Working directory /tmp/bar
 (canonically /tmp/baz/bar).
Starting program: /usr/bin/bash -c echo\ \$PATH

Actual:
/tmp/bar:[...]

Expected:
/tmp/foo/../bar
or
/tmp/baz/bar

As /tmp/bar is a directory never referenced by user above.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug cli/15145] cd and $cwd do not handle symlink/../ correctly
  2013-02-13 17:44 [Bug cli/15145] New: cd and $cwd do not handle symlink/../ correctly jan.kratochvil at redhat dot com
@ 2013-02-13 22:58 ` schwab@linux-m68k.org
  2013-02-14  7:10 ` jan.kratochvil at redhat dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: schwab@linux-m68k.org @ 2013-02-13 22:58 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15145

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> 2013-02-13 22:58:15 UTC ---
That matches the behaviour of the POSIX sh.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug cli/15145] cd and $cwd do not handle symlink/../ correctly
  2013-02-13 17:44 [Bug cli/15145] New: cd and $cwd do not handle symlink/../ correctly jan.kratochvil at redhat dot com
  2013-02-13 22:58 ` [Bug cli/15145] " schwab@linux-m68k.org
@ 2013-02-14  7:10 ` jan.kratochvil at redhat dot com
  2013-02-14 12:16 ` palves at redhat dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jan.kratochvil at redhat dot com @ 2013-02-14  7:10 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15145

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jan.kratochvil at redhat
                   |                            |dot com

--- Comment #2 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2013-02-14 07:10:41 UTC ---
But it is incorrect, it would be a POSIX bug then.

Anyway I do not see it documented in:
cd - change the working directory
http://pubs.opengroup.org/onlinepubs/007908799/xcu/cd.html

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug cli/15145] cd and $cwd do not handle symlink/../ correctly
  2013-02-13 17:44 [Bug cli/15145] New: cd and $cwd do not handle symlink/../ correctly jan.kratochvil at redhat dot com
  2013-02-13 22:58 ` [Bug cli/15145] " schwab@linux-m68k.org
  2013-02-14  7:10 ` jan.kratochvil at redhat dot com
@ 2013-02-14 12:16 ` palves at redhat dot com
  2013-02-14 13:00 ` jan.kratochvil at redhat dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: palves at redhat dot com @ 2013-02-14 12:16 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15145

Pedro Alves <palves at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |palves at redhat dot com

--- Comment #3 from Pedro Alves <palves at redhat dot com> 2013-02-14 12:16:42 UTC ---
So, taking your reproducer, you're proposing changing this behavior?

$ cd /tmp
$ cd foo
$ pwd
/tmp/foo
$ cd ..
$ pwd
/tmp

IIUC, you'd want that "cd .." from "/tmp/foo" to end up at "/tmp/baz".
That'd be quite surprising and unintuitive to me.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug cli/15145] cd and $cwd do not handle symlink/../ correctly
  2013-02-13 17:44 [Bug cli/15145] New: cd and $cwd do not handle symlink/../ correctly jan.kratochvil at redhat dot com
                   ` (2 preceding siblings ...)
  2013-02-14 12:16 ` palves at redhat dot com
@ 2013-02-14 13:00 ` jan.kratochvil at redhat dot com
  2013-02-14 14:04 ` palves at redhat dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jan.kratochvil at redhat dot com @ 2013-02-14 13:00 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15145

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #4 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2013-02-14 13:00:39 UTC ---
I got now the Comment 1 - it is not about POSIX but about real world bash.

$ touch /tmp/foo/../bar/good
$ touch /tmp/bar/bad
$ cd /tmp/foo/../bar
$ ls good bad
ls: cannot access good: No such file or directory
bad
$ _

So "cd XXX" is a different path than the one used for "touch XXX/file".

While I believe bash is wrong it is probably OK that GDB does copy the bash
behavior.

Interesting, I did not know this bash behavior.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug cli/15145] cd and $cwd do not handle symlink/../ correctly
  2013-02-13 17:44 [Bug cli/15145] New: cd and $cwd do not handle symlink/../ correctly jan.kratochvil at redhat dot com
                   ` (3 preceding siblings ...)
  2013-02-14 13:00 ` jan.kratochvil at redhat dot com
@ 2013-02-14 14:04 ` palves at redhat dot com
  2013-02-14 14:09 ` palves at redhat dot com
  2013-02-14 14:41 ` jan.kratochvil at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: palves at redhat dot com @ 2013-02-14 14:04 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15145

--- Comment #5 from Pedro Alves <palves at redhat dot com> 2013-02-14 14:03:56 UTC ---
See 8.b.:

http://pubs.opengroup.org/onlinepubs/009695399/utilities/cd.html

"For each dot-dot component, if there is a preceding component and it is
neither root nor dot-dot, the preceding component, all slashes separating the
preceding component from dot-dot, dot-dot and all slashes separating dot-dot
from the following component shall be deleted."

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug cli/15145] cd and $cwd do not handle symlink/../ correctly
  2013-02-13 17:44 [Bug cli/15145] New: cd and $cwd do not handle symlink/../ correctly jan.kratochvil at redhat dot com
                   ` (4 preceding siblings ...)
  2013-02-14 14:04 ` palves at redhat dot com
@ 2013-02-14 14:09 ` palves at redhat dot com
  2013-02-14 14:41 ` jan.kratochvil at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: palves at redhat dot com @ 2013-02-14 14:09 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15145

--- Comment #6 from Pedro Alves <palves at redhat dot com> 2013-02-14 14:09:45 UTC ---
It seems to me you could get your desired behavior by teaching GDB about "cd
-P".

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug cli/15145] cd and $cwd do not handle symlink/../ correctly
  2013-02-13 17:44 [Bug cli/15145] New: cd and $cwd do not handle symlink/../ correctly jan.kratochvil at redhat dot com
                   ` (5 preceding siblings ...)
  2013-02-14 14:09 ` palves at redhat dot com
@ 2013-02-14 14:41 ` jan.kratochvil at redhat dot com
  6 siblings, 0 replies; 8+ messages in thread
From: jan.kratochvil at redhat dot com @ 2013-02-14 14:41 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15145

--- Comment #7 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2013-02-14 14:40:59 UTC ---
-P at the newer POSIX page really explains it all, thanks.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-02-14 14:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-13 17:44 [Bug cli/15145] New: cd and $cwd do not handle symlink/../ correctly jan.kratochvil at redhat dot com
2013-02-13 22:58 ` [Bug cli/15145] " schwab@linux-m68k.org
2013-02-14  7:10 ` jan.kratochvil at redhat dot com
2013-02-14 12:16 ` palves at redhat dot com
2013-02-14 13:00 ` jan.kratochvil at redhat dot com
2013-02-14 14:04 ` palves at redhat dot com
2013-02-14 14:09 ` palves at redhat dot com
2013-02-14 14:41 ` jan.kratochvil at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).