Ticket #2227 (reopened defect)

Opened 9 years ago

Last modified 7 years ago

Unable to use Process Substitution in User Menu scripts

Reported by: ligelowbee Owned by:
Priority: minor Milestone: Future Releases
Component: mc-core Version: 4.7.2
Keywords: Cc: gotar@…
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

I was trying to use process substitution in one of my User Menu scripts but it kept kick out with:
syntax error near unexpected token `('

You can test this by making a menu entry that runs the trivial command:

echo <(ls)

She'll crapout on you nicely

My actual intent was to get a listing diff of all the files in the source and destination directories (including subdirectories) with:

%view diff -u <(find ./ -type f|sort) <(cd %D; find ./ -type f|sort)

I ended up using mktemp files instead of Process Substitution and all is well. Just thought I'd mention the troubles.

Cheers,
Lee

Change History

comment:1 Changed 9 years ago by ligelowbee

  • Version changed from version not selected to 4.7.2

comment:2 Changed 9 years ago by angel_il

  • Status changed from new to closed
  • Resolution set to invalid

try make like this

        I=`mktemp ${MC_TMPDIR:-/tmp}/1.XXXXXX`|| exit 1
        J=`mktemp ${MC_TMPDIR:-/tmp}/2.XXXXXX`|| exit 1
        find ./ -type f|sort > $I
        cd %D; find ./ -type f|sort > $J
        %view diff -u $I $J
        rm -f $I
        rm -f $J

comment:3 Changed 9 years ago by ossi

ilia: the resolution does in no way reflect on the actual issue - it demonstrates to the user the workaround he said he used anyway. i would be wondering whether you are trying to insult me or are just having an attention problem.

lee: where did you get the "syntax error" message? was it mc itself or maybe it just used a shell which does not support process substitution? iirc, mc writes out a temporary script which it executes with /bin/sh, so the latter seems plausible.

comment:4 follow-up: ↓ 9 Changed 9 years ago by ligelowbee

  • Status changed from closed to reopened
  • Resolution invalid deleted

Ossi: The error message comes from the shell. I didn't notice it was using /bin/sh. Is there a way to set mc to use bash, or maybe some other prefered shell for the menu scripts?

comment:5 Changed 9 years ago by angel_il

2Ossi: why to insult? i try to help, i give 100% solution for this case... and i think is not mc trouble.

that is why I closed this ticket.

comment:6 Changed 9 years ago by ossi

ilia, your "help" stopped where lee's report started. if you don't see this: it's the wrong way around, and thus utterly useless. you failed to dig deeper, to process the follow-up information, and to provide a halfways complete reasoning for your decision to close the issue. you wasted everyone's time (including your own) and disregarded lee's effort of reporting the issue. i find such behavior *highly* insulting. assuming you don't mean to be, you really need to work on the way how you interact with "outsiders". that way you'd also get significantly less snark from me.

comment:7 follow-up: ↓ 8 Changed 9 years ago by gotar

  • Cc gotar@… added
  1. what's that 'trivial command' supposed to be?

~: echo <(ls)
/tmp/zshmgn3jo

  1. the diff one looks wrong too:

diff -u <(find ./ -type f|sort) <(cd %D; find ./ -type f|sort)

if for example left directory has three files (a, b and c), and right only two of them (b and c) wouldn't it try to compare left-a with right-b and left-b with right-c and finish up throwing an error? The right approach is: diff -ur . %D

comment:8 in reply to: ↑ 7 Changed 9 years ago by gotar

Replying to gotar:

  1. the diff one looks wrong too:

Oh, sorry, you wanted diff of the two listings. That won't work without intermediate files in POSIX sh shell:

~: sh -c "diff -u <(find kaljsd -type f) <(find zkxjczxc -type f)"
sh: syntax error: `(' unexpected

comment:9 in reply to: ↑ 4 ; follow-up: ↓ 10 Changed 9 years ago by gotar

Replying to ligelowbee:

Ossi: The error message comes from the shell. I didn't notice it was using /bin/sh. Is there a way to set mc to use bash, or maybe some other prefered shell for the menu scripts?

bash -c "shell"?

~: sh -c "bash -c \"diff -u <(find asd -type f) <(find zxc -type f)\""

comment:10 in reply to: ↑ 9 Changed 9 years ago by ossi

Replying to gotar:

that's a somewhat dangerous idea, because it will break any quoting done by mc on the values from the expandos. one would have to assign the expandos to variables, export them and only then call the nested shell which would access the values via variables (the references to which must be escaped from the outer shell, obviously).

as far as this issue is concerned, the question is only whether we actually want to support menu files with non-posix commands natively or whether it is simply wontfix.

comment:11 Changed 7 years ago by andrew_b

  • Branch state set to no branch
  • Milestone changed from 4.7 to Future Releases
Note: See TracTickets for help on using tickets.