Conversation
|
The first commit on this branch works on macOS, but not on Linux (e.g. on CI). The difference seems to be how sh(1) handles SIGINT when run with To experiment, I wrote a little Ruby script that does nothing until it gets a SIGINT: # test.rb
begin
sleep
rescue Interrupt
puts 'SIGINT!'
endWhen I spawn a new process that runs this script directly, I can easily send it an interrupt: However, when I spawn a new process that runs the script in a shell, I can't interrupt it: Note that in this case The only vaguely useful reference to this I've found so far is a line in some Docker documentation:
|
6ba89fb to
5e5b312
Compare
| it 'parses two commands combined with |' do | ||
| result = parse(tokens( | ||
| [:WORD, 'log'], [:PIPE], [:WORD, '!wc'], [:EOS], | ||
| )) |
There was a problem hiding this comment.
Style/TrailingCommaInArguments: Put a comma after the last parameter of a multiline method call.
|
|
||
| it 'parses two commands combined with |' do | ||
| result = parse(tokens( | ||
| [:WORD, 'log'], [:PIPE], [:WORD, '!wc'], [:EOS], |
There was a problem hiding this comment.
Layout/FirstParameterIndentation: Indent the first parameter one step more than tokens(.
| def build_env | ||
| Gitsh::Environment.new( | ||
| input_stream: instance_double(IO, read: ""), | ||
| output_stream: StringIO.new |
There was a problem hiding this comment.
Style/TrailingCommaInArguments: Put a comma after the last parameter of a multiline method call.
|
|
||
| def build_env | ||
| Gitsh::Environment.new( | ||
| input_stream: instance_double(IO, read: ""), |
There was a problem hiding this comment.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
| end | ||
| end | ||
|
|
||
| def create_command_double(value=true) |
There was a problem hiding this comment.
Layout/SpaceAroundEqualsInParameterDefault: Surrounding space missing in default value assignment.
| context 'when the left command fails' do | ||
| it 'returns false' do | ||
| left_command = create_command_double(false) { '' } | ||
| right_command = create_command_double { |input| input.upcase } |
There was a problem hiding this comment.
Style/SymbolProc: Pass &:upcase as an argument to create_command_double instead of a block.
| describe '#execute' do | ||
| it 'pipes output of left command to right command' do | ||
| left_command = create_command_double { 'string' } | ||
| right_command = create_command_double { |input| input.upcase } |
There was a problem hiding this comment.
Style/SymbolProc: Pass &:upcase as an argument to create_command_double instead of a block.
| clause('.commands SEMICOLON .commands') { |c1, c2| Commands::Tree::Multi.new(c1, c2) } | ||
| clause('.commands OR .commands') { |c1, c2| Commands::Tree::Or.new(c1, c2) } | ||
| clause('.commands AND .commands') { |c1, c2| Commands::Tree::And.new(c1, c2) } | ||
| clause('.commands PIPE .commands') { |c1, c2| Commands::Pipeline.new(c1, c2) } |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [84/80]
| it 'parses two commands combined with |' do | ||
| result = parse(tokens( | ||
| [:WORD, 'log'], [:PIPE], [:WORD, '!wc'], [:EOS], | ||
| )) |
There was a problem hiding this comment.
Style/TrailingCommaInArguments: Put a comma after the last parameter of a multiline method call.
|
|
||
| it 'parses two commands combined with |' do | ||
| result = parse(tokens( | ||
| [:WORD, 'log'], [:PIPE], [:WORD, '!wc'], [:EOS], |
There was a problem hiding this comment.
Layout/FirstParameterIndentation: Indent the first parameter one step more than tokens(.
| def build_env | ||
| Gitsh::Environment.new( | ||
| input_stream: instance_double(IO, read: ""), | ||
| output_stream: StringIO.new |
There was a problem hiding this comment.
Style/TrailingCommaInArguments: Put a comma after the last parameter of a multiline method call.
|
|
||
| def build_env | ||
| Gitsh::Environment.new( | ||
| input_stream: instance_double(IO, read: ""), |
There was a problem hiding this comment.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
| end | ||
| end | ||
|
|
||
| def create_command_double(value=true) |
There was a problem hiding this comment.
Layout/SpaceAroundEqualsInParameterDefault: Surrounding space missing in default value assignment.
| context 'when the left command fails' do | ||
| it 'returns false' do | ||
| left_command = create_command_double(false) { '' } | ||
| right_command = create_command_double { |input| input.upcase } |
There was a problem hiding this comment.
Style/SymbolProc: Pass &:upcase as an argument to create_command_double instead of a block.
| describe '#execute' do | ||
| it 'pipes output of left command to right command' do | ||
| left_command = create_command_double { 'string' } | ||
| right_command = create_command_double { |input| input.upcase } |
There was a problem hiding this comment.
Style/SymbolProc: Pass &:upcase as an argument to create_command_double instead of a block.
| clause('.commands SEMICOLON .commands') { |c1, c2| Commands::Tree::Multi.new(c1, c2) } | ||
| clause('.commands OR .commands') { |c1, c2| Commands::Tree::Or.new(c1, c2) } | ||
| clause('.commands AND .commands') { |c1, c2| Commands::Tree::And.new(c1, c2) } | ||
| clause('.commands PIPE .commands') { |c1, c2| Commands::Pipeline.new(c1, c2) } |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [84/80]
|
Here’s another possibly relevant snippet of documentation from OpenBSD’s
Would it make sense for |
|
Ok, I had a play around with this and I think I got it to work: https://gist.github.com/sharplet/5dc8bd4239e09f68e8f009dbfe48f9ff#file-subshell-swift-L23. This sets up a signal handler for SIGINT that calls Using |
Two commands combined with the pipe character (`|`) will be run in parallel with the standard output of the first command connected to the standard input of the second command via an `IO.pipe`.
Two commands combined with the pipe character (
|) will be run in parallel with the standard output of the first command connected to the standard input of the second command via anIO.pipe.