question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Process substitutions are broken with magic syntax

See original GitHub issue

Process substitutions are broken. Since these use named pipes under the hood, most systems should support their use. Note, not all shells support this syntax, for example, dash does not.

Works

% head -n 100 /dev/urandom > somefile
% jc wc somefile
[
  {
    "filename": "somefile",
    "lines": 100,
    "words": 567,
    "characters": 27151
  }
]

Fails

% jc wc  <(cut -c 1-10 somefile)
wc: /proc/self/fd/11: No such file or directory
[]

workaround

% wc <(cut -c 1-10 somefile) | jc --wc
[
  {
    "filename": "/proc/self/fd/11",
    "lines": 0,
    "words": 1,
    "characters": 950
  }
]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bueckingcommented, Aug 17, 2021

I uploaded jc v1.16.1 to PyPi. Could you let me know if that works for you?

Before / After (works for me!)

 %  jc wc  <(cut -c 1-10 somefile)
wc: /proc/self/fd/11: No such file or directory
[]
 % jc -v
jc version 1.16.0
https://github.com/kellyjonbrazil/jc
© 2019-2021 Kelly Brazil

 % rehash
 % jc -v 
jc version 1.16.1
https://github.com/kellyjonbrazil/jc
© 2019-2021 Kelly Brazil
 %  jc wc  <(cut -c 1-10 somefile)
[
  {
    "filename": "/proc/self/fd/11",
    "lines": 100,
    "words": 103,
    "characters": 1059
  }
]
1reaction
bueckingcommented, Aug 13, 2021

Keep in mind you can also nest process substations, each returns a unique fd to its parent.

 % echo <(echo <(echo $((1*2))))
/proc/self/fd/11
 % cat <(echo <(echo $((1*2)))) 
/proc/self/fd/10
 % echo <(cat <(echo $((1*2))))
/proc/self/fd/11
Read more comments on GitHub >

github_iconTop Results From Across the Web

Process substitutions are broken with magic syntax · Issue #153 ...
It looks like I was able to get this working by adding the close_fds=False argument to the subprocess.Popen() function. $ jc wc <(echo...
Read more >
Process substitution not allowed by Python's subprocess with ...
/bin/sh: 1: Syntax error: "(" unexpected. You have a bashism. It is not valid according to POSIX, which is what /bin/sh implements.
Read more >
Why “process substitution” is a late feature in Unix shells
A fun trick is using the `paste` command with process substitution to combine lines of output from different commands. ./cmd1 outputs: a b...
Read more >
Chapter 23. Process Substitution
Process substitution feeds the output of a process (or processes) into the stdin of another process. Template. Command list enclosed within parentheses. >( ......
Read more >
Chapter 5: Substitutions - A User's Guide to the Z-Shell
More specifically, they allow parameter expansion, command substitution and arithmetic substitution, but not any of the others: process substitution doesn't ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found