8000 feat(shell): introduce error output behavior feature by azjezz · Pull Request #334 · azjezz/psl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(shell): introduce error output behavior feature #334

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

Merged
merged 1 commit into from
May 7, 2022

Conversation

azjezz
Copy link
Owner
@azjezz azjezz commented Feb 3, 2022

credits for this idea goes to @fredemmott ( facebook/hhvm#8946 (reply in thread) )

@azjezz azjezz added Priority: Medium This issue may be useful, and needs some attention. Status: Accepted It's clear what the subject of the issue is about, and what the resolution should be. Status: On Hold Similar to blocked, but is assigned to someone. May also be assigned to someone because of their exp Type: BC Break A change that will result in a backward compatibility break in the public API. labels Feb 3, 2022
@azjezz azjezz added this to the 2.0.0 milestone Feb 3, 2022
@azjezz azjezz self-assigned this Feb 3, 2022
@azjezz
Copy link
Owner Author
azjezz commented Feb 3, 2022

@coveralls
Copy link
coveralls commented Feb 3, 2022

Pull Request Test Coverage Report for Build 2286989541

  • 31 of 31 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 98.943%

Totals Coverage Status
Change from base Build 2286774601: -0.02%
Covered Lines: 3277
Relevant Lines: 3312

💛 - Coveralls

@Ocramius
Copy link
Contributor
Ocramius commented Feb 3, 2022

@azjezz not sure I follow 🤔

Comment on lines 7 to 56
enum ErrorOutputBehavior {
/**
* Discard the standard error output.
*/
case DISCARD;

/**
* Append the standard error output content to the standard output content.
*/
case APPEND;

/**
* Prepend the standard error output content to the standard output content.
*/
case PREPEND;

/**
* Replace the standard output content with the standard error output content.
*/
case REPLACE;
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feature behaviors to include:

  • merge: merge both stdout and stderr, the order is not guaranteed, as both streams will be read concurrently, and which ever returns first will be first, this doesn't mean that one will come after the over, as stdout can write a chunk, then stderr, then stdout, so it will be mixed ( exactly what you see in your terminal when stderr is not redirected )
  • redirect: redirect the stderr output of the process, to the stderr output of the current process.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#335 introduces a streaming function which helps implement the merge, and redirect behaviors.

@azjezz
Copy link
Owner Author
azjezz commented Feb 3, 2022

in laminas automatic release we had to disable escaping to redirect stderr to stdout, since gpg writes the key to stderr, now that is not needed since you can do:

$stderr = Shell\execute('gpg', ['--import', $keyFileName], error_output_behavior: ErrorOutputBehavior::Replace);

instead of:

$stderr = Shell\execute('gpg', ['--import', Shell\escape_argument($keyFileName), '2>&1'], escape_arguments: false);

@azjezz azjezz force-pushed the feat/shell/error-output-behavior branch 2 times, most recently from b941ee3 to 366a6ac Compare May 7, 2022 16:53
Signed-off-by: azjezz <azjezz@protonmail.com>
@azjezz azjezz force-pushed the feat/shell/error-output-behavior branch from 366a6ac to e2581de Compare May 7, 2022 16:56
@azjezz azjezz merged commit 2f9bf88 into 2.0.x May 7, 2022
@azjezz azjezz deleted the feat/shell/error-output-behavior branch May 7, 2022 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium This issue may be useful, and needs some attention. Status: Accepted It's clear what the subject of the issue is about, and what the resolution should be. Status: On Hold Similar to blocked, but is assigned to someone. May also be assigned to someone because of their exp Type: BC Break A change that will result in a backward compatibility break in the public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0