Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External panelize: opening a file with an absolute path fails #2942

Closed
mc-butler opened this issue Dec 14, 2012 · 14 comments
Closed

External panelize: opening a file with an absolute path fails #2942

mc-butler opened this issue Dec 14, 2012 · 14 comments
Assignees
Labels
area: core Issues not related to a specific subsystem prio: low Minor problem or easily worked around
Milestone

Comments

@mc-butler
Copy link

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/2942
Reporter ackalker (a.c.kalker@….com)

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.

Note

Original attachments:

@mc-butler
Copy link
Author

Changed by ackalker (a.c.kalker@….com) on Dec 14, 2012 at 5:00 UTC (comment 1)

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

@mc-butler
Copy link
Author

Changed by and on Mar 5, 2016 at 15:44 UTC (comment 2)

Confirmed, absolute paths result not respected by External panelize.

Patch attached.

@mc-butler
Copy link
Author

Changed by and on Mar 5, 2016 at 15:45 UTC

@mc-butler
Copy link
Author

Changed by and on Mar 5, 2016 at 15:45 UTC (comment 3)

  • Milestone changed from Future Releases to 4.8.16

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Mar 5, 2016 at 21:20 UTC (comment 4)

  • Milestone changed from 4.8.16 to 4.8.17

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Apr 30, 2016 at 20:59 UTC (comment 5)

  • Milestone changed from 4.8.17 to 4.8.18

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Apr 30, 2016 at 21:00 UTC (comment 6)

:-(

@mc-butler
Copy link
Author

Changed by zaytsev (@zyv) on Sep 22, 2016 at 19:37 UTC (comment 7)

  • Milestone changed from 4.8.18 to 4.8.19

@mc-butler
Copy link
Author

Changed by mooffie (@mooffie) on Apr 18, 2017 at 17:34 UTC (comment 8)

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

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.)

@mc-butler
Copy link
Author

Changed by mooffie (@mooffie) on Apr 18, 2017 at 17:41 UTC (comment 9)

  • Branch state changed from no branch to on review

branch: 2942_panelize_absolutize
Initial [c9f058e]

@mc-butler
Copy link
Author

Changed by mooffie (@mooffie) on Apr 18, 2017 at 17:44 UTC

@mc-butler
Copy link
Author

Changed by andrew_b (@aborodin) on Apr 20, 2017 at 10:33 UTC (comment 11)

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

@mc-butler
Copy link
Author

Changed by mooffie (@mooffie) on Apr 20, 2017 at 17:29 UTC (comment 12)

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

Merged to master: [e0cd82a]

@mc-butler
Copy link
Author

Changed by mooffie (@mooffie) on Apr 20, 2017 at 17:38 UTC (comment 13)

  • Status changed from testing to closed

NEWS-4.8.20 updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues not related to a specific subsystem prio: low Minor problem or easily worked around
Development

No branches or pull requests

2 participants