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

Use PATH environment variable for Filtered View #59

Closed
wants to merge 1 commit into from
Closed

Use PATH environment variable for Filtered View #59

wants to merge 1 commit into from

Conversation

woodsb02
Copy link
Contributor

mc does not use the PATH environment variable to search for the executable when performing a Filtered View command.

The filtered view command is run with the mc_popen function in lib/utilunix.c. This function runs the process with the glib function g_spawn_async_with_pipes, which by default requires the full path of the executable.

This change adds the G_SPAWN_SEARCH_PATH flag to the g_spawn_async_with_pipes function call, which causes mc to use the PATH environment variable to search for the executable.

mc does not use the PATH environment variable to search for the executable when performing a Filtered View command.

The filtered view command is run with the mc_popen function in lib/utilunix.c. This function runs the process with the glib function g_spawn_async_with_pipes, which by default requires the full path of the executable.

This change adds the G_SPAWN_SEARCH_PATH flag to the g_spawn_async_with_pipes function call, which causes mc to use the PATH environment variable to search for the executable.
@woodsb02
Copy link
Contributor Author

To replicate the problem:

  1. In mc, open the "File" menu and select "Filtered View"
  2. In the displayed Filtered View command and arguments field, type "grep PATTERN FILENAME"

Expected result: display output of grep command in mcview
Actual result: Error is displayed "Cannot create pipe streams"

Reason: The grep command is not in the current directory, and the PATH environment variable is not used to search for the executable.

@woodsb02
Copy link
Contributor Author

@aborodin
Copy link
Member

Applied as 544a6b6.
Thanks!

@aborodin aborodin closed this Apr 19, 2015
@woodsb02
Copy link
Contributor Author

Thanks for the commit :)

@armangithub
Copy link

do you know which release of MC contains or will contain the fix ?
I have the same issue in MC 4.8.14.
Thanks.

@ActualizeInMaterial
Copy link

This issue seems to be back: when doing an F3 on a .patch file, I get the red window: Cannot create pipe streams

The script that was created as a result, as /tmp/mc-z/mcextDCNDJY, seems to be working when I manually execute it.

Its contents are these:

#! /bin/sh

MC_EXT_FILENAME=/home/z/build/1packages/pacman-git/pacman-sync-first-option.patch
export MC_EXT_FILENAME
MC_EXT_BASENAME=pacman-sync-first-option.patch
export MC_EXT_BASENAME
MC_EXT_CURRENTDIR=/home/z/build/1packages/pacman-git
export MC_EXT_CURRENTDIR
MC_EXT_SELECTED="pacman-sync-first-option.patch"
export MC_EXT_SELECTED
MC_EXT_ONLYTAGGED=""
export MC_EXT_ONLYTAGGED

 /usr/lib/mc/ext.d/misc.sh view cat

It even works if I invoke it with empty PATH like:
$ PATH= ./mcextDCNDJY

Hmm, actually this happens for .tar files too.

$ mc --version
GNU Midnight Commander 4.8.17-33-gcb06f8c
Built with GLib 2.48.1
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
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, fish
Data types: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;

@ActualizeInMaterial
Copy link

ActualizeInMaterial commented Jun 21, 2016

oh I see what's up... 5251045

G_SPAWN_SEARCH_PATH got removed ...
EDIT: I guess it's more complicated than just adding that back. I'll let someone knowledgeable fix it :)
EDIT2: So, apparently the command aka argv[3] here
is /bin/sh /tmp/mc-z/mcext1739IY which it kinda makes sense not to work then.
Edit3: /bin/sh added from here

EDIT4: ok ignoring all that, the actual error is:
Failed to execute child process "/bin/sh" (Bad address)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants