Ticket #2942 (closed defect: fixed)

Opened 4 years ago

Last modified 9 days ago

External panelize: opening a file with an absolute path fails

Reported by: ackalker Owned by: mooffie
Priority: minor Milestone: 4.8.20
Component: mc-core Version: master
Keywords: Cc:
Blocked By: Blocking: #3767
Branch state: merged Votes for changeset: committed-master

Description

What version of Midnight Commander is used?

$ LC_MESSAGES=C mc -V
GNU Midnight Commander 4.8.6
Built with GLib 2.32.4
Using the S-Lang library with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm and Linux console
With support for X11 events
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, fish, smbfs
Data types: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;

What steps will reproduce the problem?

  1. Create a test HTML file (content doesn't matter):

$ touch /tmp/t.html

  1. In Midnight Commander, select Command -> External Panelize
  1. as Other Command / Command, enter:

echo /tmp/t.html

  1. In the panelized listing, select the file /tmp/t.html and press Enter to open it.

What is the expected output?

The HTML file should open in my webbrowser

What do you see instead?

(using PCManFM) an Error popup saying "No such file or directory".

After editing the extension file to change the html / open action, I found that Midnight Commander is trying to open the file ${HOME}/tmp/t.html instead of /tmp/html.
Note. Viewing and editing files with absolute paths in External panelize works without problems.

Change History

comment:1 Changed 4 years ago by ackalker

I.e.: the variable MC_EXT_FILENAME appears to be set to ${HOME}/tmp/t.html instead of /tmp/t.html

comment:2 Changed 14 months ago by and

Confirmed, absolute paths result not respected by External panelize.

Patch attached.

comment:3 Changed 14 months ago by and

  • Milestone changed from Future Releases to 4.8.16

comment:4 Changed 14 months ago by zaytsev

  • Milestone changed from 4.8.16 to 4.8.17

comment:5 Changed 12 months ago by zaytsev

  • Milestone changed from 4.8.17 to 4.8.18

comment:6 Changed 12 months ago by zaytsev

:-(

comment:7 Changed 7 months ago by zaytsev

  • Milestone changed from 4.8.18 to 4.8.19

comment:8 Changed 11 days ago by mooffie

  • Owner set to mooffie
  • Status changed from new to accepted

Summary

When "External panelize" or "File find" think the result (the file list) has absolute paths, they set the panel's cwd_vpath property to "/" (and chdir() to there). This makes everything work (like patterns of the form "%d/%p" (there will be a double "/" at the beginning but that's harmless on POSIX systems), and ctrl+shift+enter for putting an absolute path on the command-line).

The bug's immediate cause

For "External panelized", there's a bug in how do_external_panelize() detects absolute paths: it looks in the zero'th element (the "..") instead of the 1'st one.

The bug's real cause

MC has several panelization-related bugs (I'll open tickets for individual bugs as time goes by). They all have one cause: lack of source-code documentation. This leads, as MC evolves and its code changes, to bugs because the intentions of the original programmer are lost.

As for @and's patch

@and's patch doesn't fix the "real cause". Also, as my branch shows, there are seveal more fixes to be done. I went to the lengths of giving him credit in the 1st commit, though. (His optimization for the "\n" trimming will be handled in #3811 instead; "#define LABELS" in #3780.)

comment:9 Changed 11 days ago by mooffie

  • Branch state changed from no branch to on review

branch: 2942_panelize_absolutize
Initial changeset:c9f058e65bc18ee1e6b1874733863df4746d075f

comment:10 Changed 11 days ago by mooffie

  • Blocking 3767 added

comment:11 Changed 9 days ago by andrew_b

  • Votes for changeset set to andrew_b
  • Branch state changed from on review to approved

comment:12 Changed 9 days ago by mooffie

  • Status changed from accepted to testing
  • Votes for changeset changed from andrew_b to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

comment:13 Changed 9 days ago by mooffie

  • Status changed from testing to closed

NEWS-4.8.20 updated.

Note: See TracTickets for help on using tickets.